D Deleted member 103 Guest Dec 27, 2021 #1 Hi, The CSV file (see attachment) can be imported in B4a, but not in B4i. But if you convert the CSV file to UTF8, then it can be read in B4i. B4X: Dim lstCSV As List = File.ReadList(File.DirDocuments, "test.csv") Is it possible to automatically convert a CSV file to UTF8 format so that the user does not have to do anything when creating the file? Attachments Test.zip Test.zip 307 bytes · Views: 338
Hi, The CSV file (see attachment) can be imported in B4a, but not in B4i. But if you convert the CSV file to UTF8, then it can be read in B4i. B4X: Dim lstCSV As List = File.ReadList(File.DirDocuments, "test.csv") Is it possible to automatically convert a CSV file to UTF8 format so that the user does not have to do anything when creating the file?
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2021 #2 Use CSVParser + File.ReadString2 with the correct encoding. [B4X] CSVParser - CSV parser and generator Upvote 0
Use CSVParser + File.ReadString2 with the correct encoding. [B4X] CSVParser - CSV parser and generator
D Deleted member 103 Guest Dec 27, 2021 #3 Erel said: Use CSVParser + File.ReadString2 with the correct encoding. [B4X] CSVParser - CSV parser and generator Click to expand... I have already tried this and it does not work either. B4X: Dim parser As CSVParser parser.Initialize Dim lstCSV As List = parser.Parse(File.ReadString2(File.DirDocuments, "test.csv", "UTF-8"), ";", False) Log("lstCSV.size= " & lstCSV.size) lstCSV.size= 0 Click to expand... Upvote 0
Erel said: Use CSVParser + File.ReadString2 with the correct encoding. [B4X] CSVParser - CSV parser and generator Click to expand... I have already tried this and it does not work either. B4X: Dim parser As CSVParser parser.Initialize Dim lstCSV As List = parser.Parse(File.ReadString2(File.DirDocuments, "test.csv", "UTF-8"), ";", False) Log("lstCSV.size= " & lstCSV.size) lstCSV.size= 0 Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2021 #4 It is not utf8. Try windows-1252 Upvote 0
D Deleted member 103 Guest Dec 27, 2021 #5 Erel said: It is not utf8. Try windows-1252 Click to expand... I know that it is not utf8. I have already tried windows-1252 and all possible formats, unfortunately without success. Upvote 0
Erel said: It is not utf8. Try windows-1252 Click to expand... I know that it is not utf8. I have already tried windows-1252 and all possible formats, unfortunately without success.
Erel B4X founder Staff member Licensed User Longtime User Dec 28, 2021 #6 Code: Dim s As String = File.ReadString2(File.DirAssets, "Test.csv", "iso-8859-1") Upvote 0
D Deleted member 103 Guest Dec 28, 2021 #7 Erel said: Code: Dim s As String = File.ReadString2(File.DirAssets, "Test.csv", "iso-8859-1") Click to expand... Hi Erel, of course I have also tried with this format, unfortunately also without success. B4X: Dim s As String = File.ReadString2(File.DirAssets, "Test.csv", "iso-8859-1") log("s=" & s) Log output: s= Click to expand... Meanwhile I think the error is in the routine "ReadString2", because I can't imagine that it doesn't give an error message if it can't read the file. As already written, the file is read in Android without problems. Question: did you try to read the file with B4i? Upvote 0
Erel said: Code: Dim s As String = File.ReadString2(File.DirAssets, "Test.csv", "iso-8859-1") Click to expand... Hi Erel, of course I have also tried with this format, unfortunately also without success. B4X: Dim s As String = File.ReadString2(File.DirAssets, "Test.csv", "iso-8859-1") log("s=" & s) Log output: s= Click to expand... Meanwhile I think the error is in the routine "ReadString2", because I can't imagine that it doesn't give an error message if it can't read the file. As already written, the file is read in Android without problems. Question: did you try to read the file with B4i?
Erel B4X founder Staff member Licensed User Longtime User Dec 28, 2021 #8 Filippo said: Question: did you try to read the file with B4i? Click to expand... Of course. Works fine here. Attachments Project.zip Project.zip 8.7 KB · Views: 343 Upvote 0
Filippo said: Question: did you try to read the file with B4i? Click to expand... Of course. Works fine here.
D Deleted member 103 Guest Dec 28, 2021 #9 Erel said: Of course. Works fine here. Click to expand... Hi Erel, you are right as always. ? I just noticed that the CSV file "Test_Timekeeper_komma.csv" was empty (see screenshot). It can only happen when copying, because in Finder has a size of 191 bytes and in iPhone 0 bytes. Attachments Bildschirmfoto 2021-12-28 um 09.42.14.jpg 156.5 KB · Views: 386 Upvote 0
Erel said: Of course. Works fine here. Click to expand... Hi Erel, you are right as always. ? I just noticed that the CSV file "Test_Timekeeper_komma.csv" was empty (see screenshot). It can only happen when copying, because in Finder has a size of 191 bytes and in iPhone 0 bytes.
E emexes Expert Licensed User Longtime User Dec 28, 2021 #10 Filippo said: I just noticed that the CSV file "Test_Timekeeper_komma.csv" was empty (see screenshot). Click to expand... This misnaming feels like a trap for future programmers. Upvote 0
Filippo said: I just noticed that the CSV file "Test_Timekeeper_komma.csv" was empty (see screenshot). Click to expand... This misnaming feels like a trap for future programmers.