Loading a searchview with only 3 columns not complete list

CD Tom

Member
Licensed User
Longtime User
I am loading my searchview from a csv file that has many columns, I only want to load the first three.
B4X:
   If FirstTime Then
      Dim members As List
      members = File.ReadList(File.DirAssets, "MBRS.csv")
      index = SV1.SetItems(members)
   Else
      SV1.SetIndex(index)
   End If
members becomes a very large file with lots for information not needed for the search.
Is there any way to limit the file.readlist to only the first three columns of the MBRS.csv file?
If you need more code let me know.
The information is loaded into a database from the same MBRS.csv if I could get the members out of there I think it would work better.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
SearchView doesn't really intended to work with more than one column. In your code you treat each raw line as a single item.

You can iterate over the members list and find the first three items in each line and add it to another list. Then you can add the second list to SearchView.
I can help you with the parsing code.
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
Ok, let's give that a try but I'll need some help, I'm learning but it's a slow process. In order to help with the code do you need anything more from me?
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
Erel,
I was able to figure out a way to build the list from the database and it works great. Here's what I did
B4X:
   members.Initialize
   Dim cursor1 As Cursor
   Dim Vmlname As String
   Dim Vmfname As String
   Dim vmnumber As Int
   Dim VList As String
   cursor1 = SQL1.ExecQuery("Select mbr_number, mbr_last_name, mbr_first_name from mbrs")
   Dim Rcount As Int
   
   For i = 0 To cursor1.RowCount -1
      cursor1.Position = i
      Vmlname = cursor1.GetString("mbr_last_name")
      Vmfname = cursor1.GetString("mbr_first_name")
      vmnumber = cursor1.GetInt("mbr_number")
      VList = (Vmlname & "," & Vmfname & "," & vmnumber)
      members.Add(VList)
   Next
   cursor1.Close
don't know if that's what you had in mind but it seems to be working.
Now have another question pertaining to this same program. Don't know if I should start another thread but hear it is.
Once a month I will get a new mbrs.csv file how do I go about making sure that the file that gets loaded as the most current one.
I will extract the file out of the access database on the main computer how do I get it into the app or the directory where the app will read it.
I'm sure this is very confusing
Thanks for all your help.
 
Last edited:
Upvote 0
Top