janisdd / vscode-edit-csv

vs code extension to edit csv files with an excel like table ui
MIT License
211 stars 30 forks source link

Odd auto detect behavior #119

Closed snakehill closed 1 year ago

snakehill commented 1 year ago

It seems that the delimiter auto detect is very easily tricked when multiple common delimiters are present, even if just once.

The following (fake but realistic data) will split at the comma (,) instead of at the semicolon (;), even though the semicolon is all over whereas each line only contains one comma:

April 15, 2023;4028722987;25.00;4.00;16.00;Ray;pending;
April 14, 2023;4441335566;25.00;4.00;16.00;Scott;pending;
April 14, 2023;1012167625;25.00;4.00;16.00;Paige;pending;
April 13, 2023;5595193937;25.00;4.00;16.00;Antone;pending;
April 12, 2023;3329268556;25.00;4.00;16.00;Theron;pending;
April 11, 2023;7187180132;25.00;4.00;16.00;Brandy;pending;
April 10, 2023;1327553107;25.00;4.00;16.00;Lupe;pending;
April 9, 2023;6783434534;25.00;4.00;16.00;Lonny;
April 9, 2023;6387478020;25.00;4.00;16.00;Rosa;
April 8, 2023;7795581629;25.00;4.00;16.00;Cecelia;

I would think it should be looking at either the last character or the most appearing (non-escaped) character, before assuming it's supposed to be the first appearing delimiter instead.

janisdd commented 1 year ago

Interesting one... but actually quite simple, your data format is "corrupted"

The last 3 lines have only 7 fields, the others 8.

If you make all rows the same length, it works as expected.