node-csv
node-csv copied to clipboard
One CSV to Another and strip 0x00 characters
I have a Pipe Delimited CSV (Source) like:
COLUMN 1|COLUMN 2|COLUMN 3
VALUE A1|VALUE A2|VALUE A3
VALUE B1|VALUE B2|VALUE B3
I want a CSV (Target) like:
"COLUMN 1","COLUMN 2","COLUMN 3"
"VALUE A1","VALUE A2","VALUE A3"
"VALUE B1","VALUE B2","VALUE B3"
How do I go about:
- Writing the source to a Target without going through "for loops" or "mapping" as it creates memory error on very large csv?
- Also in this process, remove all 0x00 (unprintable) characters ?
Will appreciate it if I can have a small sample on this.
https://csv.js.org/parse/recipes/stream_pipe/ all the information for what's being asked is here. If you have 0x00 it sounds like you have UTF-16 you can try setting encoding https://csv.js.org/parse/options/encoding/
@kitsunde Thanks,
Problem is that I do not know what format the CSV is in that the client upload (UTF-16, UTF-8, etc). This can be any of these.
https://www.npmjs.com/search?q=charset-detection there's a lot of libraries that can help you detect encoding.