mechatroner / vscode_rainbow_csv

🌈Rainbow CSV - VS Code extension: Highlight CSV and TSV files in different rainbow colors to make them more readable
MIT License
417 stars 51 forks source link

Odd autodetect behavior #134

Closed snakehill closed 1 year ago

snakehill commented 1 year ago

It seems the delimiter autodetect is very easily tricked when multiple of the autodetect characters are present, even if just once. With the default settings (both ; and , set up), 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 has 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, prior to assuming it's supposed to be the first appearing delimiter instead.

snakehill commented 1 year ago

Apparently it does work if the column lengths are the same. Somehow I had a database being exported with an additional semicolon in the end (or rather trailing semicolons being trimmed from the other rows).