iOS Question Wrong number of values, saveTabletoCsv

John Woodsmall

Active Member
Licensed User
Longtime User
ok
I have figured out where the file is that I can write to(File.DirCocuments,"history.csv")
When I run this I get "'Wrong number of values." in the log.
and when I open the table later, there is not a new row added?
The file:history.csv has 7 fields separated by "," like a regular csv file.




B4X:
Private Sub Application_Start:
Table4.SetColumnsWidths(Array As Int(100dip,100dip,100dip,100dip,100dip,100dip,100dip, 100%x - 700dip))
sub End

B4X:
Sub AddTofile_click
     '
    ' First_name,Last_name,birth_date,birth_time,birth_state,birth_st_abv,birth_city
    '
    If File.Exists(File.DirDocuments,"History.csc") Then
        Person1_Saved= First_Name_1.Text & "," & Last_Name_1.Text
        Person1_Saved = Person1_Saved & "," & lblfirstDate.Text & "," & LblTime.Text
        Person1_Saved = Person1_Saved & "," &  State.Text & "," &  Temp_TextField.text & "," & City.TEXT
        Table4.AddRow(Array As String(Person1_Saved))
        Table4.SaveTableToCSV(File.DirDocuments, "History.csv")
    Else
        File.Copy(File.DirAssets,"History.csv" ,File.DirDocuments,"History.csv")
       Person1_Saved= First_Name_1.Text & "," & Last_Name_1.Text
        Person1_Saved = Person1_Saved & "," & lblfirstDate.Text & "," & LblTime.Text
        Person1_Saved = Person1_Saved & "," &  State.Text & "," &  Temp_TextField.text & "," & City.TEXT
       Table4.AddRow(Array As String(Person1_Saved))
    End If
 

Attachments

  • history.csv.txt
    40 bytes · Views: 337

John Woodsmall

Active Member
Licensed User
Longtime User
Still have this problem.
1.) moved the history.csv to the File.DirDocuments
2.) made the string into a correct comma delimited text string with quotes.
3.) msgbox shows string with the quotes and the commas as expected.
3.) still get "Wrong Number of Values" when I try to insert.
4.) if instead i use a string in the function, it works:
Table4.AddRow(Array As String("John","Woodsmall","08/12/1942","16:25:00","Texas","TX","Houston"))

5.) Need help.

6.) must be something about the "array as string function".


B4X:
If File.Exists(File.DirDocuments,"History.csv") Then
        Person1_Saved= QUOTE  & First_Name_1.Text & QUOTE & "," & QUOTE & Last_Name_1.Text & QUOTE & ","
        Person1_Saved = Person1_Saved & QUOTE  & lblfirstDate.Text & QUOTE & "," & QUOTE &  LblTime.Text & QUOTE & ","
        Person1_Saved = Person1_Saved & QUOTE  & State.Text & QUOTE & "," & QUOTE &  Temp_TextField.text & QUOTE & "," 
        Person1_Saved = Person1_Saved & QUOTE & City.TEXT & QUOTE
        '
        Msgbox (Person1_Saved,"")
        'Table4.AddRow(Array As String("John","Woodsmall","08/12/1942","16:25:00","Texas","TX","Houston"))
        'Table4.AddRow(Person1_Saved)
        Table4.AddRow(Array As String(Person1_Saved))
        Table4.SaveTableToCSV(File.DirDocuments, "History.csv")
        'Msgbox ("file exits","")
 
Upvote 0
Top