Page 1 of 1

csv using filewrite

Posted: May 16th, 2024, 12:39 pm
by amari
I am using filewrite to create csv file with encode option to generate some dashboard data,my resulted csv I need to import to mysql database,but when I try importing it's complaining about hidden character in every field and my import get failed. does filewrite add invisible character to file or how I can workaround here

Re: csv using filewrite

Posted: May 16th, 2024, 4:32 pm
by aaronw
There's a lot going on here. Can you try creating a csv file with a single entry by hand and then import it. At least this will let you know if the issue is with the CSV or somewhere else.

Re: csv using filewrite

Posted: May 17th, 2024, 7:57 am
by Gregory Martin
The extra character is likely the UTF-8 BOM. Files created using the File object add those three characters at the beginning of the file. You can get around this by using the CSV Data Source:

https://www.csprousers.org/help/CSPro/d ... e_csv.html

The property encoding=UTF-8 will not write the BOM.

Alternatively, you can continue what you're doing, and then when finished:

1) Close your file.

2) Use File.readText to read all the text: https://www.csprousers.org/help/CSPro/C ... dText.html

3) Use File.writeText to write the text without the BOM, specifying the encoding as UTF-8: https://www.csprousers.org/help/CSPro/C ... eText.html

Re: csv using filewrite

Posted: May 17th, 2024, 11:36 am
by amari
Thanks lot