Cant find much tutorial on here for reading from a .csv file, i found some code using StringUtils but its not reading the pc.csv file i have placed in the 'Files' folder. I get...
B4X:
java.io.FileNotFoundException: /mnt/sdcard/pc.csv: open failed: EACCES (Permission denied)
Here's what i borrowed in the hope of logging the results....
Which line is wrong??
B4X:
Sub Globals
Dim List1 As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(File.DirRootExternal, "pc.csv"))
Dim line As String
line = Reader.ReadLine
List1.Initialize
Do While line <> Null
Dim LineArray() As String
LineArray = Regex.Split(";", line)
Log(LineArray)
'List1.Add(LineArray)
line = Reader.ReadLine
Loop
End Sub
Sub Activity_Create(FirstTime As Boolean)
How would i say populate the listview with the first line??
AB11, AB12 etc
Activity.LoadLayout("csv_listview")
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(File.DirAssets, "pc.csv"))
Dim line As String
line = Reader.ReadLine
Do While line <> Null
Dim LineArray() As String
LineArray = Regex.Split(";", line)
ListView1.AddSingleLine(LineArray)
line = Reader.ReadLine
Loop
End Sub
The CSV file reads into the ListView a list of arrays. This is why you don't see your data yet. You will have to pull the data out of the array element before you add it to the listview.