[SOLVED] Do not use QuoteChar when save csv lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- totya · 2023-02-03 21:04 Hi Master! If I load and save same csv file, the result is different, see: input: Quotea   b   c öüó   őúé    áűí 123    456   789 output: (save) Quotea   b   c öüó   "őúé "   áűí "123 "   456   789 But I must do not need QuoteChar when I save csv file, can I do it anyhow? Thank you! Code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MenuItem1Click(Sender: TObject);begin  CSVParams.Encoding:='UTF-8';  CSVParams.Delimiter := #9; //CSVParams.QuoteChar :=  ???   sWorksheetGrid1.LoadFromSpreadsheetFile('Src\test.csv', sfCSV);  sWorksheetGrid1.SaveToSpreadsheetFile('Src\test_OUT.csv', sfCSV);end; ---------------------------------------------------------------------- wp · 2023-02-07 16:57 No "master", please... It seems that quotes are added when a cell text ends (or begins) with a space. Looking into the csvdocument sources (which are used by fpspreadsheet) I see that there is a boolean option "QuoteOuterWhiteSpace" which is active by default. When you open file fpscsv.pas, find procedure TsCSVWriter.WriteSheet, add the line "FCSVBuilder.QuoteOuterWhiteSpace := CSVParams.QuoteOuterWhiteSpace;" after the "try", and add a "CSVParams.QuoteOuterWhiteSpace :=false;" to your project code the quotes will be gone. I committed an updated version of fpspreadsheet in which the TCSVParams record is extended by the following fields: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TsCSVParams = record   // W = writing, R = reading, RW = reading/writing    ...    QuoteOuterWhiteSpace: Boolean;   // W: Quote when cell content begins/ends with white space.    IgnoreOuterWhiteSpace: Boolean;  // R: Ignores white space before/after cell content.    ....  end; As you can see you can also set CSVParams.IgnoreOuterWhiteSpace to true to get rid of the leading/trailing spaces already at reading - then these cells will not be quoted either. But note that the white-space options do not work for numerical cells since the string-to-float conversion occurs via the standard function TryStrToFloat which does a "trim" (white-space removal) before the conversion. ---------------------------------------------------------------------- Thaddy · 2023-02-07 17:06 What is so difficult in understanding escaped chars? https://en.wikipedia.org/wiki/Escape_character To be honest @wp gave you a much more elaborate answer than the question deserved. He has more patience... ---------------------------------------------------------------------- totya · 2023-02-07 18:30 Quote from: wp on February 07, 2023, 05:57:30 pmNo "master", please... Hi! I call you "master" long time ago (years), because this is the biggest component what I seen ever on the world, and this component helped me a lot. But okay! Your completely understand my problem (not like others) thank you! I uninstall fps comoonent via online package manager. First uninstall nothing happen, but the second uninstall is success. Next I install svn version, success. Unfortunately,  CSVParams.QuoteOuterWhiteSpace := False; doesn't work. Code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.LoadCSVMenuItemClick(Sender: TObject);begin  CSVParams.Encoding := 'UTF8';  CSVParams.Delimiter := #9;  CSVParams.QuoteOuterWhiteSpace := False;   Memo.Lines.Add('Loading...');  Application.ProcessMessages;   sWorksheetGrid1.LoadFromSpreadsheetFile('Src\test.csv', sfCSV);  sWorksheetGrid1.SaveToSpreadsheetFile('Src\test_OUT.csv', sfCSV);end;     input: Quotea   b   c öüó   őúé    áűí 123    456   789 output: Quotea   b   c öüó   "őúé "   áűí "123 "   456   789 ---------------------------------------------------------------------- wp · 2023-02-07 19:04 Oh, there's a typo in the writer code - fixed. Please get yourself the latest commit. ---------------------------------------------------------------------- totya · 2023-02-07 19:11 Quote from: wp on February 07, 2023, 08:04:31 pmOh, there's a typo in the writer code - fixed. Please get yourself the latest commit. Perfect, works, thank you wp!