csv using filewrite
csv using filewrite
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
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.
-
- Posts: 1882
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: csv using filewrite
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
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