Android Question [Help Needed] Why does this cause an error for SaveCSV

konradwalsh

Active Member
Licensed User
Longtime User
Hello
I have try to put a string array into a list and save it to a csv file

B4X:
Dim myRegexSolution As String = $"\s+(?=(?:[^"]*"[^"]*")*[^"]*$)"$ ' splits at spaces outside quotes
Dim SplitValues() As String = Regex.split(myRegexSolution,myHtmlResponse)
                           
Dim list1 As List
                                list1.Initialize
                                            For Each item As String In SplitValues
                                                list1.Add(item)
                                            Next

                          
  StringUtils1.SaveCSV(File.DirRootExternal & "/TestSP/", "Result.CSV", ",", list1)

I get this error
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.String[]

I see that its saying I am trying to cast an array into variable
however, If print the list1 it appears correct to me...

clearly I have missed something obvious
 

konradwalsh

Active Member
Licensed User
Longtime User
thanks for helping out...

Yes, I want to write an entire CSV in one go.

the
myHtmlResponse
is a simple list like so -
B4X:
"Product 1", "Product adcfvc", "Product  654", "Product hdfgh"

I am starting to wonder that since the 'myHtmlResponse' is formed that way.. maybe I should just write it to a file called "whatever.CSV"

Then I can just use it later....
 
Upvote 0
Top