Android Question Import CSV

LA3QMA

Member
Licensed User
Longtime User
I'm trying to use LoadCSV() from the stringutils.

My data is stored like:

"field1" TAB "field2" TAB "field3"
"field1" TAB "field2" TAB "field3"

Using the LoadCSV() with separators like , ; : works ok.
The data is exported from another tool and i cannot change the separator.

Have tried using:

LoadCSV("dir", "somefile", "|")
LoadCSV("dir", "somefile", TAB)
LoadCSV("dir", "somefile", Asc(9))

I can always remove the " before inserting to sqlite using regexp or some other strtool.

But how can i separate the fields ?
 

LA3QMA

Member
Licensed User
Longtime User
Yes it was Chr i was using, Asc was a typo.

But i'm getting the error:
StringIndexOutOfBoundsExeption
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem of your file is the format.
It is UTF-16LE but Android expects UTF-8
I saved your file with Notepad++ with UTF-8 without BOM encoding and it works!
I looked at the file with TotalCommander in hex format and saw that all characters have two bytes.
You can read the file into the application with UTF-16LE and save it again with UTF-8 encoding.
Attached my test program, it includes your new file save with Notepad++ and also the reading and saving.
 

Attachments

  • Test.zip
    28.2 KB · Views: 355
Last edited:
Upvote 0

LA3QMA

Member
Licensed User
Longtime User
Thank you very much :) When making the app i tested with a "home made file" and not an actual exported file. When trying the exported file my app did not work.
Probably need more coffee as i did check the file with an hex-editor but did not see anything strange.

Thanks again :)
 
Upvote 0
Top