adaltas / node-csv

Full featured CSV parser with simple api and tested against large datasets.
https://csv.js.org
MIT License
4.05k stars 267 forks source link

Return value in cast example #418

Closed BigGillyStyle closed 6 months ago

BigGillyStyle commented 9 months ago

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?

wdavidw commented 9 months ago
  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 commented 6 months ago

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.