csv using filewrite

Discussions about creating CAPI applications to run on Android devices
Post Reply
amari
Posts: 36
Joined: February 24th, 2024, 11:29 am

csv using filewrite

Post 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
aaronw
Posts: 571
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: csv using filewrite

Post 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.
Gregory Martin
Posts: 1882
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: csv using filewrite

Post 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
amari
Posts: 36
Joined: February 24th, 2024, 11:29 am

Re: csv using filewrite

Post by amari »

Thanks lot
Post Reply