Search() function with external CSV file

Hi, I am searching an external csv file with the select one search(‘csvfile’) appearance, but my CSV file contains 8k lines (street names). It’s making the form freeze for 5 or 6 seconds when I get to this question. I tried using minimal autocomplete(‘csvfile’), with no success. Tried minimal search(‘csvfile’), and this solved the freezing problem, the list is poping up instantly, but I no longer can type a search, having to scroll down the 8k lines list to find the street. I tried using a default value for the field, but with no success.

All I want is the list to not pre load all streets and freeze the app, I need it to start showing results only after 3 or 4 typed chars typed.

Any ideas?

Thanks in advance and sorry for my English!

Hi @percezione,

Have you tried using the autocomplete in the appearance? Tryout the steps as mentioned and this should help sort out your problem:

  • If you are designing the form in XLSForm, you simply need to type autocomplete in the appearance column against the question.
  • If you are using the KoBoToolbox Formbuilder Interface, in the question, click to the setting button > Appearance (Advanced): > other > (type) autocomplete
  • Click to SAVE and you are done.
1 Like

Hey @Kal_Lam, thanks for replying my question again!

I am using Excel to create my forms, I should note that I am using the KoboCollect Android App to submit my forms.
But how am I supposed to connect the autocomplete with the external csv file?
When I use autocomplete(‘csvfile’) I get no results
select_one_external nor select_one_from_file works…

Hi @percezione,

Try using the search search() function under the appearance as shown in the image below:

Image 1 (survey tab):
Image%201

Image 2 (choices tab):
Image%202

Image 3 (csv file):


Note: in your dataset you will see 1 if you select Apple, 2 if you select Watermelon and so on. However, if you wish to see Apple, Watermelon etc. simply type Apple, Watermelon under the name as well.

Steps:

  • Finalize your survey forms as shown in image 1 & 2.
  • Finalize your choices list (for the csv file) as shown in image 3.
  • Upload your survey xlsform in KoBoToolbox.
  • Deploy your survey project.
  • Upload your csv file (SETTINGS>Media>Add Document).

Reference Files:
search search().xlsx (12.6 KB)
fruits.csv (522 Bytes)

1 Like

Hi @Kal_Lam, thank you very much for your help.
Unfortunately using the search search(‘csv’) didn’t make any diference in the form (I’m using KoBoCollect), The fruits from the CSV file were showing as soon as you open the question. And when you have a 8k fruits csv, it freezes the KoboCollect App.

But I got the solution from the ODK Forum, user @mathieubossaert gave me instructions on some search() options that are not documented. Such as:

  • startswith
  • endswith
  • contains
  • matches

search(‘csvName’, ‘contains’, ‘columnsToSearch’, ${search_string})

So what I did was: I created another question in the form, to store a search_string, and in the next question I searched the csv file for that string.

Its one more page in the form, but It’s working great.

Thansk again!

1 Like

Hi @percezione,

Great that you finally found out the solution. Could you be kind enough to share your xlsform with the csv file so that other community members could benefit from the issue that you lodged. THANK YOU in Advance!

A post was split to a new topic: How do i link external csv files with my survey questionnaire?

A post was split to a new topic: Linking a response with an external file (csv)