node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

Return value in cast example

Open BigGillyStyle opened this issue 1 year ago • 1 comments

When I used the "cast" example as-is, I got the error message:

CsvError: Option columns missing name: property "name" is required at position 0 when column is an object literal
    at normalize_columns_array (/Users/apickler/rocket/rockethomes/tmp/mls_csv_compare/node_modules/csv-parse/dist/cjs/index.cjs:36:15)
    at Object.__firstLineToColumns (/Users/apickler/rocket/rockethomes/tmp/mls_csv_compare/node_modules/csv-parse/dist/cjs/index.cjs:1067:35)
    at Object.__onRecord (/Users/apickler/rocket/rockethomes/tmp/mls_csv_compare/node_modules/csv-parse/dist/cjs/index.cjs:943:21)
    at Object.parse (/Users/apickler/rocket/rockethomes/tmp/mls_csv_compare/node_modules/csv-parse/dist/cjs/index.cjs:835:40)
    at Parser._transform (/Users/apickler/rocket/rockethomes/tmp/mls_csv_compare/node_modules/csv-parse/dist/cjs/index.cjs:1331:26)

It would seem to me (and what works for me locally) is that when you don't need to cast a particular column, that you just want to return the unmodified value?

BigGillyStyle avatar Feb 09 '24 18:02 BigGillyStyle

  1. Could you add a unit test (you could submit it in js if not confortalbe with coffee) to your merge request ?
  2. "When I used the "cast" example as-is", please share an example (or the unit test will be enough to understand how to reproduce)

wdavidw avatar Feb 10 '24 13:02 wdavidw

I enriched the cast documentation page with a new usage sample that preserve a value as is. Hopefully it will answer your concern. Otherwise feel free to open a new issue.

wdavidw avatar Apr 24 '24 16:04 wdavidw