vscode-edit-csv icon indicating copy to clipboard operation
vscode-edit-csv copied to clipboard

Unexpected quoting of cell values that contain leading or trailing spaces

Open tartale opened this issue 5 months ago • 7 comments

What OS?

  • Mac

Description

When working with a file that has cells with leading or trailing spaces, quotes are always added to those cells, ignoring the values of the related settings:

"csv-edit.newColumnQuoteInformationIsQuoted": false,
"csv-edit.quoteAllFields": false,
"csv-edit.quoteEmptyOrNullFields": "false",
"csv-edit.retainQuoteInformation": true,

Expected behavior

When loading, modifying, and saving a file with the above settings, existing cell values that have extra spaces should not be automatically quoted.

Steps to reproduce

I've only tried this with pipe "|" delimiters, but the following example should demonstrate the issue...

  • Create a file (e.g. "test.csv" with the following contents:
foo     |   bar  |biz
baz     |boz| buz 
  • Make a minor change to one of the cells and save: Screenshot 2024-09-19 at 2 44 40 PM

  • Quotes are introduced into the original file:

"foo     "|"   bar  "|bizb
"baz     "|boz|" buz "

Per the rules described here, I assumed that the row starting with foo would be used to determine quotes, and none of the cells in that row have quotes.

It's possible that this is correct behavior, or that the settings to get the behavior I want are different than what I'm using.

The desired behavior would be very useful when working with files that have aligned columns.

Workaround

I found a workaround with the Rainbow CSV extension; if I "shrink" values, then use Edit CSV, and then re-align columns, I can get the end result I wanted, but the extra steps are a bit tedious.

tartale avatar Sep 19 '24 20:09 tartale