do you cats use any external libraries to parse CS...
# suitescript
b
do you cats use any external libraries to parse CSV files?
s
i think there is snippets already from the N/file module that'll parse them
b
parsing csv becomes a lot more complicated when you have to handle the escape characters
s
b
can I load the papaparse min file in my define or do I have to import via relative path
b
im not sure what the difference between those 2 are
s
Copy code
.split(/(?!\B"[^"]*),(?![^"]*"\B)/);
I split with this normally, it doesn't split commas in speech marks ^_^"
b
ok, thank you
s
if you are going to do it manually like that, you might want to use array destructuring to concisely pull out the columns to variables (assuming SS2.1)
b
Thank @stalbert I want to use the column headers instead of splitting on , and then counting the columns to get the data I want, that is the reason for the question in the first place
s
you'd probably already be done if you were using papaparse.
b
@stalbert @battk so one issue is I have to send papaparse a string of the CSV and the file is 170 MB so I can't load vs getContents, any way to get around this
b
hope there are no character escapes and use string splitting
alternatively hope you know how to write a token parser
b
That's what I feared but thought I'd ask
b
id actually look into modifying papaparse to support netsuite's file streaming
papaparse supports streaming, just not how netsuite implements it