ODK-X: Assign value from external csv

Hi all,

I have an external csv-file containing, region, region_nr, village, village_nr and, cluster_nr.
Using queries and two select_one_dropdown prompts the intviewer first chooses region and then village.

Is it possible to save cluster_nr to a new variable when village is chosen, or assigning cluster_nr to a new variable from the saved values of region and village?

The queries-sheet look like the region/country example: https://docs.opendatakit.org/odk-x/xlsx-converter-using/#id7

Hi!

So I have not done this but I could think of two possible ways to try:

  1. Add in the queries sheet the column fieldName. For the last level of the dropdowns, enter cluster_nr in fieldName
  2. See in query sheet the gov_csv, kism_csv, shyakha_csv quest1_00_0.xlsx (457.5 KB) . I have not tried this, but in the line “_.map(context, function(place){
    place.name = place.shyakha;
    place.label = place.shyakha;
    place.data_value = place.name;
    place.display = {title: {text: place.label} };
    return place;
    })”
    I would guess you can change something there to pull cluster_nr instead.

Someone may have actually done this and be better able to answer.

Hi @elmps2018

Thanks for the suggestions.

  1. I cannot figure out if it will work to pull a value from a csv. Well if it’s possible I cannot get it to work.

  2. By changing place.data_value = place.cluster_nr, I should be able to pull the value, but my problem is that i need to pull both a village and a cluster value, I can’t figure out to pull both at a time.

I don’t know quite how to do this properly in ODK, but I do know how we set our csvs up to make option 2. happen; if you need to pull both a village and a cluster value and clusters are within villages, you can create the cluster value so it includes the village value.

Example starting data:
V C
1 1
1 2
2 1
2 2

You can revise this data to be
V C
1 1_1
1 1_2
2 2_1
2 2_2

Then when you have the cluster you also essentially have the village; or you can at least extract it.

There’s probably a better way to do this, but this might work…