Search() function with external CSV file

1. What is the problem? Be very detailed.

I am trying to use the search function with an external CSV file.
SELECT_ONE ....... SEARCH('STREETS.CSV')
It's working, but I have 8k lines in this CSV file, so, when I open the form question on the Collect App, it freezes for 5 or 6 seconds before showing the list with the streets. When I start typing it filters the street names perfect.

My problem is with the freezing. Is there a way to not pre load all street names and only start showing results after 3 or 4 characters?

2. What app or server are you using and on what device and operating system? Include version numbers.

KoboToolBox servers

3. What you have you tried to fix the problem?

I've tried autocomplete('csvfile') with no success
I've tried the minimal appearance - It doesn't let me search, just gives me a dropdown list
I've tried select_one_from_file csvfile.csv - It doesn't load the CSV file
I've tried select_one_external csvfile.csv - It doesn't load the CSV file

4. What steps can we take to reproduce the problem?

Just try to search on a external CSV file with 8k lines.

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hi Bruno.
Welkome to thé odk community.

You will need to make use of search() options such as startswith() or contains().
We use it to filter matching lines into 400000 species name.
For the moment the documentation page is not complete ans you'll find the description of those options here : Looking for an old documentation page about search() function

"search(csvName, 'startswith', columnsToSearch, searchText)": This search expression includes all distinct rows that start with the specified text in the specified column(s) (e.g., "search('hhplotdata', 'startswith', 'respondentname', ${nameprefix})"). The third parameter specifies either a single column name to search, or a comma-separated list of column names to search. Rows with matches in any specified column will be included."

1 Like

@mathieubossaert
Thanks very much for your help! Indeed there is no documentation for those options!
Thanks a lot! I was stuck on this for 3 days.

Much love from Recife - Brasil!

Just one more question: I had to add another field, (text search string) then in the next page I show the searched results with this search string. Is there a way to make it all happen in the same page?

Hi Bruno,

yes you can :slight_smile:
Try the field-list appearence for your group of questions : https://odk-demo.readthedocs.io/en/latest/form-widgets.html#field-list

Mathieu

1 Like