Android Question Array to List

jeffnooch

Member
Licensed User
Longtime User
I'm trying to use SaveCSV and it says it needs Table as List

is there an easy way to convert an array to a list?

essentially i have dim arr(5,36) as Int
and i just want to dump what is in the array into a csv file...

anyone have a quick example?
thanks
 

DonManfred

Expert
Licensed User
Longtime User
anyone have a quick example?
There is no built-in support to export/import a multidimensional array.
I guess you need to build your own export-sub
 
Upvote 0

jeffnooch

Member
Licensed User
Longtime User
This is the best i could come up with...seems to work...any suggestions for improvement?
NOTE: myArray was defined earlier as 'Dim myArray(170,6) As String
thanks

B4X:
Sub OutputFile
    Dim lstSave As List
    Dim arrHdr() As String
    Dim vFile As String
    Dim vDate As String
    Dim su As StringUtils
    lstSave.Initialize
    DateTime.DateFormat = "yyyyMMdd-HHmm"
    vDate = DateTime.Date(DateTime.Now)
    vFile = "testcsv-" & vDate & ".csv"
    arrHdr = Array As String("col1","col2","col3","col4","col5","col6")
    For vRow =  0 To myArray.Length-1
        Dim arrRow(6) As String 'Create a new array of 6 elements -- ie one for each column
        For vCol = 0 To 5
            arrRow(vCol) = myArray(vRow,vCol)
        Next
        lstSave.Add(arrRow)  
    Next
    su.saveCSV2(File.DirRootExternal,vFile,",",lstSave,arrHdr)
End Sub
 
Upvote 0

Similar Threads

Top