I have an importer that is supposed to upload a special file from a third-party program. The file is structured as follows:
TITLE,DESCRIPTION,PRICE,CURRENCY_CODE,QUANTITY,TAGS
"This is the file title","This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.",12.99,USD,10,"Tag1,Tag2,Tag3"
"Next line","This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.",12.99,USD,10,"Tag1,Tag2,Tag3"
"Next line","This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.",12.99,USD,10,"Tag1,Tag2,Tag3"
I am trying to read this file line by line, which unfortunately does not work in JS.
const reader = new FileReader();
reader.onload = async (evt) => {
const file = evt.target.result.split('rn')
When I open the file in Numbers (Mac = Excel) and save via File > Export > CSV > Text encoding Unicode (UTF-8), the file is spit out as follows:
TITLE;DESCRIPTION;PRICE;CURRENCY_CODE;QUANTITY;TAGS
"This is the file title";"This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.";12.99;USD;10;"Tag1;Tag2;Tag3"
"Next line";"This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.";12.99;USD;10;"Tag1;Tag2;Tag3"
"Next line";"This is the file description and it can include line breaks
Size: 16x16
Weight: 1,5
for example here
more information.";12.99;USD;10;"Tag1;Tag2;Tag3"
I can work wonderfully with this file formatting. As i can see, all columns are now marked via ;
and the line break evt.target.result.split('rn')
works as well.
Unfortunately, I cannot assume that my users will be able to convert this file.
Therefore, I would like to convert the file as Numbers does when uploading it.
How does this work via JavaScript new FileReader() ?