# ODK: Preload choices using csv attachments

**URL:** <https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133>\
**Category:** Support\
**Tags:** odk-central, odk-build, odk-xlsform\
**Created:** [August 5, 2025, 6:24pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133 "2025-08-05T18:24:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 5, 2025, 6:24pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/1 "2025-08-05T18:24:37Z")

</div>

**1. What is the issue? Please be detailed.**  
i am trying to preload choices using an external csv file as an attachment and i get just the drop down with no choice, i am using this syntax .  
search('facilities\_data')  
search('facilities\_data', 'matches', 'state', ${state})  
search('facilities\_data', 'matches', 'lga', ${lga})  
search('facilities\_data', 'matches', 'ward', ${ward})  
search('facilities\_data', 'matches', 'ward', ${ward})

and yet i can't get to see any choices  
**2. What steps can we take to reproduce this issue?**  
upload the final version of the programmed xlsx and also the csv for attachments

**3. What have you tried to fix the issue?**  
i have tried to upload and also use documentations to practice yet nothing  
**4. Upload any forms or screenshots you can share publicly below.**

[facilities\_data.csv](https://forum.getodk.org/uploads/short-url/4Ggq5BMQ4VBgCRH6pGH9yqsAWGG.csv) (838.0 KB)  
[Innovius\_Facility\_dummy.xlsx](https://forum.getodk.org/uploads/short-url/zEatKSVajmcRXu46LtqZpPFKpwk.xlsx) (17.0 KB)

---

<div class="post-metadata">

**Author:** ![Francis\_Opiyo](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/francis_opiyo/32/13835_2.png) [@Francis\_Opiyo](https://forum.getodk.org/u/Francis_Opiyo)\
**Post date:** [August 6, 2025, 7:45pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/2 "2025-08-06T19:45:58Z")

</div>

Some edits done here. Tested and confirmed functional for all the aforementioned select\_one fields.  
One of the key issues identified was putting applying the search external file function on the state and at the same time including list of state names in the choices sheet. In this case, I remove state entries on choices sheet and used the state in the external file.  
[Innovius\_Facility\_dummy.xlsx](https://forum.getodk.org/uploads/short-url/dWYm7vbM0bUQSgQi9sDc5THI4um.xlsx) (16.6 KB)  
[facilities\_data.csv](https://forum.getodk.org/uploads/short-url/4Ggq5BMQ4VBgCRH6pGH9yqsAWGG.csv) (838.0 KB)

---

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 6, 2025, 8:08pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/3 "2025-08-06T20:08:19Z")

</div>

Thank you very much for this insightful edit. I should test it and get back immediately.

---

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 7, 2025, 9:16am UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/4 "2025-08-07T09:16:58Z")

</div>

@Francis_Opiyo I just ran the form upload, but I couldn't attach the CSV because it said "This definition requires no attachments, so there is nothing to upload" so i can't upload the attachements is there a reason why this is so?. Just wanting to make sure i get it right

---

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 7, 2025, 9:20am UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/5 "2025-08-07T09:20:13Z")

</div>

![image](https://getodk.b-cdn.net/uploads/default/original/3X/3/0/30658b157c01f193a9e7fcb754d2a4e58bf7f441.png)  
here is a an example of what i am explaining, here i can't upload the csv attachment

---

<div class="post-metadata">

**Author:** ![Francis\_Opiyo](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/francis_opiyo/32/13835_2.png) [@Francis\_Opiyo](https://forum.getodk.org/u/Francis_Opiyo)\
**Post date:** [August 7, 2025, 9:38am UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/6 "2025-08-07T09:38:52Z")

</div>

Apologies I tested with ODK aggregate. I did not have access to any ODK central instance. A quick question though, Were you able to upload seamlessly before?

---

<div class="post-metadata">

**Author:** ![Stephen\_K\_ojwang](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/stephen_k_ojwang/32/7727_2.png) [@Stephen\_K\_ojwang](https://forum.getodk.org/u/Stephen_K_ojwang)\
**Post date:** [August 7, 2025, 10:39am UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/7 "2025-08-07T10:39:22Z")

</div>

I see you are not referencing the external csv files. Can you make the select one to point to this; select\_one\_from\_file facilities\_data.csv and then add the "parameters" column then for the row of lga insert in the cell "value=lga\_code, label=lga" Do the same for ward "value=ward\_code, label=ward" and hf\_name "value=hf\_name\_code, label=hf\_name" (adding the code and label appropriately). If necessary include allow\_choice\_duplicates to yes in the setting. I hope this will help. But it is strongly suggested to make facilities\_data an entity to enjoy the efficiency that comes with this. Let me know if you succeed.

---

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 7, 2025, 12:04pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/8 "2025-08-07T12:04:31Z")

</div>

Thank you but a quick question to ensure i understand what you mean, i should maintain the lines of syntax on appearance while using select\_one from\_file? and how do i make the csv an entity ? thanks

---

<div class="post-metadata">

**Author:** ![jniles](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/jniles/32/2819_2.png) [@jniles](https://forum.getodk.org/u/jniles)\
**Post date:** [August 7, 2025, 2:59pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/9 "2025-08-07T14:59:16Z")

</div>

Hi @Marcell_Okoubi ,

I've included a working example using ODK Central for the `search()` field. Here are your files:

[facilities\_data.csv](https://forum.getodk.org/uploads/short-url/4Ggq5BMQ4VBgCRH6pGH9yqsAWGG.csv) (838.0 KB)  
[Innovius\_Facility\_dummy.xlsx](https://forum.getodk.org/uploads/short-url/sFhS2bjIy1ZV3gprndKr6qgQ31C.xlsx) (16.3 KB)

I've included a working GIF example of it in action here:

![ODKSearchFields](https://getodk.b-cdn.net/uploads/default/original/3X/0/f/0fb83d79e62131f27c9fa0ef533ccd398eb8a77a.gif)

Do note that `search()` is deprecated and will likely be removed in the future. The `select_one_from_file` is the recommended solution. Also, `search()` **will not work** in the web-based data collection forms. This is why you must use a phone to test it (as my GIF shows). If you plan on using web forms, please use a supported solution.

As @Francis_Opiyo stated, the issue with your original version was two-fold:

1. You were using "state\_code" to filter the data, but filtering on the "state" column. I have modified my form to filter on "state\_code", but you could easily switch it to filter and keep "state" instead, assuming your "state" names are all unique. I personally always use a unique ID that I can map back to the names because names can sometimes be surprisingly not unique.
2. You had multiple lists named "state" in the "choices" worksheet, which led to the confusing errors. Removing those cleaned it up and helped identify the real issue in (1).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Marcell\_Okoubi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/marcell_okoubi/32/30708_2.png) [@Marcell\_Okoubi](https://forum.getodk.org/u/Marcell_Okoubi)\
**Post date:** [August 7, 2025, 4:55pm UTC](https://forum.getodk.org/t/odk-preload-choices-using-csv-attachments/56133/10 "2025-08-07T16:55:41Z")

</div>

Thank you this worked on the device, but didn't on the web, i would send these version for the device for review and figure a way for it to work on the web. @jniles
