Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One CSV to Another and strip 0x00 characters #329

Open
1Map opened this issue Mar 17, 2022 · 3 comments
Open

One CSV to Another and strip 0x00 characters #329

1Map opened this issue Mar 17, 2022 · 3 comments

Comments

@1Map
Copy link

1Map commented Mar 17, 2022

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:

  1. Writing the source to a Target without going through "for loops" or "mapping" as it creates memory error on very large csv?
  2. Also in this process, remove all 0x00 (unprintable) characters ?

Will appreciate it if I can have a small sample on this.

@kitsunde
Copy link

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/

@1Map
Copy link
Author

1Map commented Jun 10, 2022

@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.

@kitsunde
Copy link

https://www.npmjs.com/search?q=charset-detection there's a lot of libraries that can help you detect encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants