Android Question cant add all the rows in table format

Shripal Dalal

Member
Licensed User
Longtime User




i am using this above code to bind my csv data, but it is adding only 1st row in table and does not iterate loop 2nd time.

can any1 point out that am i making any mistake in my code?
below is my code

B4X:
Dim list1,list2 As List
list1.Initialize()
list2.Initialize()

SetHeader(Array As String("No.", "Location", "Mrp", "Disc", "TotalAmt"))

    list1=sf.Split(strGlobalReportString, "~")             '' splitting rows
            For i=0 To list1.Size-1
                list2=sf.split(list1.Get(i), "!")                 '' splitting columns of individual row
                If list2.Size > 0 Then
                   AddRow(Array As String(i, list2.Get(0), list2.Get(1), list2.Get(2),list2.Get(3)))
               End If
            Next
 
Last edited:

klaus

Expert
Licensed User
Longtime User
How do you read the csv file?
Do you use the LoadCsv or LoadCsv2 method from the StringUtils library ?

The Flexible Table class includes a routine to import csv files into the table.
 
Last edited:
Upvote 0

Shripal Dalal

Member
Licensed User
Longtime User
How do you read the csv file?
Do you use the LoadCsv or LoadCsv2 method from the StringUtils library ?

The Flexible Table class includes a routine to import csv files into the table.






what i am doing is:- I get results in single line from sql as follows:
1!x!y!z~2!a!b!c~

so i am splitting the columns(~) then after rows (!)
i use for loop and it works fine in all other forms with lisview controls.
but here i am adding it in array as string and that is fetching only 1st row.
B4X:
list1=sf.Split(strGlobalReportString, "~")             '' splitting rows
            For i=0 To list1.Size-1
                list2=sf.split(list1.Get(i), "!")                 '' splitting columns of individual row
                If list2.Size > 0 Then
                  ''listviewSummary.AddTwoLines2(list2.Get(0),list2.Get(1),list2.Get(0))
                   AddRow(Array As String(i, list2.Get(0), list2.Get(1), list2.Get(2),list2.Get(3)))
               End If
            Next
 
Upvote 0

Shripal Dalal

Member
Licensed User
Longtime User
Maybe you mean "last Row"!?


i meant 1st row i.e: 1!x!y!z out of 1!x!y!z~2!a!b!c~

i moved the dim of list2 inside the loop
loop executes only once. it adds row in table and then it goes out of loop even though there are 2 records.
actually loop should execute twice but it doesn't and That is the main problem.
 
Upvote 0

Shripal Dalal

Member
Licensed User
Longtime User
hey guys i solved the problem.

I did thorough debugging and tried "j" instead of "i" as counter in loop and it worked.
B4X:
For j=0 To list1.Size-1
rest of the things are working fine as expected. splitting function is also fine without any problem.

thank you all for the suggestions & help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…