Hi -
I'm re-posting the post as it was deleted by Erel for thinking I posted it in wrong forum.
I have small application that I wrote in b4i and I have 4 tables that I would like to export to CSV. I have found couple posts :
www.b4x.com
www.b4x.com
I have tried to use stringutils to save a list to CSV as suggested, but that I got errors - after bit of searching, it's recommend to the use CSV Parser.
While I can save bit of couple columns of the table to CSV, it won't save all rows :
I understand that I'm overwriting S with another line, which is my problem - but I can't seem to save the list of rows to the CSV + I wasn't able to save all my columns - do I need to worry about special characters with this parses?
Hope you can help.
Thanks
Jiri
I'm re-posting the post as it was deleted by Erel for thinking I posted it in wrong forum.
I have small application that I wrote in b4i and I have 4 tables that I would like to export to CSV. I have found couple posts :
[B4X] Cross platform Editable B4XTable + Form Example
This example demonstrates several things: Cross platform code and files, similar to the way XUI2D games are organized: All the logic is implemented in a class named EditableTable. The module is located in the projects parent folder. The two asset files (list of animals - source; and the...
[B4X] CSVParser - CSV parser and generator
CSV - comma separated values format. The various StringUtils libraries include methods for loading and saving CSV files. However these methods have a few drawbacks: - They work with files instead of strings. This is especially problematic if the input is not UTF8 encoded. - As they are...
I have tried to use stringutils to save a list to CSV as suggested, but that I got errors - after bit of searching, it's recommend to the use CSV Parser.
While I can save bit of couple columns of the table to CSV, it won't save all rows :
B4X:
Dim myParser As CSVParser
myParser.Initialize
Dim myData As List
myData.Initialize
Dim rs As ResultSet = mySQL.ExecQuery("SELECT * FROM Retailer")
Do While rs.NextRow
Dim t As String = rs.GetString("retID") & "," & rs.GetString("retName") & "," & rs.GetString("retLocation")
Dim myTable As List = myParser.Parse(t, ",",False)
For Each row() As String In myTable
'work with row
Next
Dim s As String = myParser.GenerateString(myTable,",")
Loop
rs.Close
File.WriteString(File.DirDocuments, "table.csv", s)
I understand that I'm overwriting S with another line, which is my problem - but I can't seem to save the list of rows to the CSV + I wasn't able to save all my columns - do I need to worry about special characters with this parses?
Hope you can help.
Thanks
Jiri