TAdvStringGrid Import with "simple" CSV

Hi everyone,

I have an problem with some CSV-Files I have from an vendor for office supplies.
They send me files with the char >"< inside the description like '5 1/4" Floppy'
(just as an example). With the normal ImportFromCSV in the TAdvStringGrid
this couses my software to read 10000 articles instead of the real 20000 articles.
One option to correct this would be an better check for the handling of
multi line cells in "TAdvStringGrid.InputFromCSVStream", so that a >"< is only
respected when it's after the semicolon (or any other delimiter).
The simple way is an additional option like "RespectMultiLineCellOptionOnCSVImport"
so that the source could be extended like
  // handle multiline cells
  if (NOT FRespectMultiLineCellOptionOnCSVImport) OR (MultilineCells) then
    s := 0;
I hope you can improve the benefit for these "simple CSV-Files".

Greetings from Papenburg, Germany
 Gabriele Hillebrandt

The CSV format prescribes that a single double quote is exported in CSV as a double double-quote, i.e. a correct notation for CSV would be:

... abc,"5 1/4"" Floppy", def, ..

Hello Mr. Fierens,

I totally agree with this! My problem is, that vendors can do everything and I have to
make thinks work. For example they send really wrong data, like a wrong price
and I have to check it with some strange filters.
This is, why I beg for this change in your source, otherwise I have to do
it on every TMS-update myself.

Greetings from Papenburg, Germany
 Gabriele Hillebrandt

I have retested this here with a CSV file

test,5 1/4" floppy,size

and loading it in a default grid with grid.LoadFromCSV('file.csv'); and this is importing 5 1/4" floppy into a single cell. So, even with this, I cannot see an issue.

Hi Mr. Fierens,

indeed, this will work, but this not:
g;5 1/4" Disk;h
l;some more 5 1/4" Floppys;m
it makes the area from first " to secound " to one line.

Greetings from Papenburg, Germany
 Gabriele Hillebrandt

In this case, it indeed goes wrong.
Well, it feels a bit strange to patch the grid for incorrect CSV files, but we added a public property CSVMultilineCellImport: boolean to deal with such broken files.

Thanks a lot for this!
This would save a lot of work and administration effort.
You may should add some comment like
"just for those freaky vendors in germany" ;-)

Have fun and prosperity!

Greetings from Papenburg, Germany
 Gabriele Hillebrandt

I just saw this, and the funny thing is I recently had the same problem.

Yes, in a way it is a bit odd to accommodate improper file syntax, but sometimes we have no control over how others format the data that we must use.

Thanks for taking that into consideration!