Skip to content

Commit 73addde

Browse files
authored
Create select_from_file_xls.md
1 parent 52b0b54 commit 73addde

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

source/select_from_file_xls.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Selecting options from an external file
2+
3+
**Select from file** questions allow you to use a list of choice options stored in an external file instead of defining them directly in your form. There are two types: `select_one_from_file` for selecting a **single choice**, and `select_multiple_from_file` for selecting **multiple choices**.
4+
5+
Using a separate file for your choice list makes it easier to manage long lists, reuse them across multiple forms, and update options when needed. Supported file formats include CSV, XML, and GeoJSON.
6+
7+
This article explains how to format your external file, set up your XLSForm to use **select from file** questions, and upload your external file to KoboToolbox.
8+
9+
<p class="note">
10+
<strong>Note:</strong> This article focuses on adding select from file questions in <a href="https://support.kobotoolbox.org/getting_started_xlsform.html">XLSForm</a>. To learn about adding select from file questions in the KoboToolbox Formbuilder, see <a href="https://support.kobotoolbox.org/external_file.html">Select One or Many From External File Question Type</a>.
11+
<br><br>
12+
For hands-on practice with select from file questions in XLSForm, see KoboToolbox Academy’s <a href="https://academy.kobotoolbox.org/courses/xlsform-fundamentals">XLSForm Fundamentals Course</a>.
13+
</p>
14+
15+
## Formatting external choice lists
16+
17+
To get started, create your list of choices in a separate external file. The required structure of this file depends on the format you choose (CSV, XML, or GeoJSON). Use a separate file for each choice list.
18+
19+
<p class="note">
20+
To learn more about formatting XML or GeoJSON files, see <a href="https://xlsform.org/en/#multiple-choice-from-file">XLSForm</a> and <a href="https://docs.getodk.org/form-datasets/#building-selects-from-geojson-files">ODK documentation</a>. GeoJSON files are primarily used for <a href="https://support.kobotoolbox.org/select_from_map_xls.html">selecting options from a map</a>.
21+
</p>
22+
23+
For CSV files, the structure is similar to the choices worksheet in an XLSForm. It should include the `name` and `label` columns, but the `list_name` column is not needed.
24+
25+
**External CSV file**
26+
27+
| name | label |
28+
|:--------|:----------|
29+
| option1 | Option 1 |
30+
| option2 | Option 2 |
31+
| option3 | Option 3 |
32+
33+
If your file uses different names for the choice name and label, you can specify this in your XLSForm (see instructions [below](https://support.kobotoolbox.org/select_from_file_xls.html#configuring-choice-name-and-label-columns)).
34+
35+
<p class="note">
36+
<strong>Note:</strong> Use short, simple file names for your external files, avoiding spaces or special characters. The file name will be used in your XLSForm to link questions to their choice lists. If you use multiple external files, make sure each one has a unique name, even if they use different file types.
37+
</p>
38+
39+
## Setting up your XLSForm
40+
41+
To add a select from file question to your XLSForm:
42+
1. In the `type` column of the `survey` worksheet, enter the select from file question type (`select_one_from_file` or `select_multiple_from_file`).
43+
2. In the same cell, instead of the choices `list_name`, add a single space and the name of the external file, including the file extension.
44+
- For example: `select_one_from_file households.csv`
45+
46+
**survey worksheet**
47+
48+
| type | name | label |
49+
|:-------------------------|:-----|:----------------|
50+
| select_one_from_file households.csv | hh | Select household |
51+
| survey |
52+
53+
### Configuring choice name and label columns
54+
55+
If your external file uses different column names instead of `name` and `label`:
56+
1. Add a **parameters** column to the `survey` worksheet
57+
2. In the select from file question row, specify the custom names with the `value` and `label` parameters.
58+
- `value` represents the choice **name**.
59+
- `label` represents the choice **label**.
60+
61+
**survey worksheet**
62+
63+
| type | name | label | parameters |
64+
|:-------------------------|:-----|:-----------------|:-----------------------------|
65+
| select_one_from_file households.csv | hh | Select household | value=housenum label=housename |
66+
| survey |
67+
68+
## Uploading the external file to KoboToolbox
69+
70+
When uploading your XLSForm to KoboToolbox, you must also upload the external file that contains your list of choices:
71+
1. In KoboToolbox, navigate to the project **SETTINGS** page.
72+
2. In the **Media** tab, upload the external file. Ensure the file name matches exactly the file name specified in the XLSForm.
73+
74+
To update your list of choices, edit the external file as needed, re-upload it to KoboToolbox, and redeploy your form.
75+
76+
![Upload media](images/select_from_file_xls/upload_media.png)
77+
78+
## Troubleshooting
79+
80+
<details>
81+
<summary><strong>Translated choice lists</strong></summary>
82+
Select from file questions do not currently support <a href="https://support.kobotoolbox.org/language_xls.html">translated choice lists</a>. Your external choice file can include only a single <code>label</code> column. Any additional translated <code>label</code> columns will be ignored in Enketo or will cause an error in KoboCollect. For forms that include translations, use internal choice lists instead, or set up multiple <strong>select from file</strong> questions using skip logic to pull from different files depending on the form language.
83+
</details>
84+
85+
86+

0 commit comments

Comments
 (0)