Using of odkmeta command

1. What is the problem? Be very detailed. I downloaded the data from odk Aggregate with odk briefcase.

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

3. What you have you tried to fix the problem?
I want to import in stata by using odkmeta in order to have the label but it doesn't work. Every time I have the following messaage:

4. What steps can we take to reproduce the problem?
there is the command i used:
odkmeta using import.do, csv("$data_dir/surveydata.csv") survey("$data_dir/survey.csv") choices("$data_dir/choices.csv")

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

column header type not found
invalid type() suboption
invalid survey() option

Welcome @dogkas!

There are different reasons for which you might be seeing this error message. There have been a couple of topics in the forum with related discussion. If you haven't already, first try reviewing those, then let us know if you still have questions:

Also, when you get a chance, please introduce yourself here. Doing so helps build community!

Hello everybody and especially Matthew!
I tried to do as you indicaded in the above message but my issue remain.
I use Stata 14. So as I exported my csv files in ASCII and restarted the run but the issue is not fixed. I have the same message:
column header type not found
invalid type() suboption
invalid survey() option
r(111);

Does your XLSForm contain non-ASCII characters, such as characters with diacritics or the character (which is subtly different from the ASCII character ')? That's often one cause of this error message. Also, are you able to share your XLSForm here for troubleshooting purposes?

Hi Matthew
There's my XLSform hereENQUETE_IFDD_GUINEE_BISSAU_2019.xls (45 KB)

From a first glance, I do see characters with diacritics (for example, â and é). That means that when you save the survey and choices sheets as CSV, they are exported as Unicode, which odkmeta currently does not understand. As long as those characters only appear in labels, the simplest solution is probably just to replace them with ASCII characters (for example, replacing â with a). Once you make those replacements, you should be able to export the sheets as ASCII, not Unicode.

@Matthew_White
Hi Matthew! I am new to the community and I have used ODK a few times to carry out data collection. I am using the odkmeta command in Stata 16 and facing some issues.

I use the following command:
odkmeta using odkdo, csv(data.csv) survey(survey.csv) choices(choices.csv)

where I have extracted the survey and choices sheets from the main tool and converted them into CSV (Comma Delimited)

I get the following error:
column header label not found
invalid label() suboption
invalid survey() option

I am attaching the tool. Is there a problem with the csv conversion and ASCII characters? I couldn't wrap my head around that.
Tool_ODKforum.xlsx (87.0 KB)

Hi @smritisaini, and welcome to the ODK forum! When you have a chance, I'd encourage you to introduce yourself here. Doing so helps build community!

Your XLSForm does contain non-ASCII characters, but I think they should be easy to remove. The survey sheet has the columns hint:Nepali and label:Nepali, and the choices sheet has the column label:Nepali. You'll need to delete those columns before exporting to CSV so that the CSV file does not contain those characters. Other than that, I don't think your XLSForm contains any non-ASCII characters.

Next, I see a row in the survey sheet that will be an issue for odkmeta: row 18 has a type and a label but no name. You will probably want to delete that row before exporting to CSV.

Last but not least — and this may be the source of the error message you're seeing — odkmeta needs to know the name of the label column. By default, it looks for a column named label. One option is to rename the label:English column to label before exporting to CSV. Alternatively, you can tell odkmeta to use the label:English column by specifying the label() suboption:

odkmeta using odkdo, csv(data.csv) survey(survey.csv, label(label:English)) choices(choices.csv, label(label:English))

Hope this helps!

Hello friends,

I need help here. I am trying to import my data into Stata. I have used this command, but everything else is imported except for the labels. Importing the labels is important because it will save the time I would have spend to retype them within stata itself. I have tried everything I can think of to resolve this issue, but no success. Kindly assist

odkmeta using odkmeta1, csv("C:\Users\pmusi\Downloads\ADA SPRS_NU Endline Evaluation Survey Questionnaire_New.csv") survey("C:\Users\pmusi\Downloads\survey.csv") choices("C:\Users\pmusi\Downloads\choices.csv")

Hi @Musinguzi_Polycarp! Based on the screenshot, it looks like the odkmeta do-file resulted in an error. The odkmeta do-file must run to completion without error in order for the import to be successful.

I'm not sure what the source of this error message is. How are you downloading your submission data? Note that odkmeta is designed to import data that matches the ODK Briefcase export CSV format. Also, if you to use ODK Briefcase, don't remove group names when you export.

Hope that helps!

Hello Matthew,
You're right. I used briefcase to download the data but had removed the group names, After including the group names, everything works fine and I now have the dataset with the value labels.

Thanks so much for your timely assistance

1 Like

I'm glad that worked! Note also that the odkmeta help file has instructions on how to remove the group names from within Stata if that would be helpful.

Hello Matthew,

Thanks for the guidance, but I am not exactly sure how or what command to run to eliminate the group names. However, for now, I have had to remove them manually. I am attaching screenshots of the command I have run (as per the help file) as well as my dataset where the group names remain. Would appreciate it if you could further guide me on how to accomplish this task. I must admit that while I often try to find my way around these sort of issues, I am not really a tech-savvy guy and often find that I need more help than others.

2021-03-06 Thanks a lot

In this case, you will need to edit the odkmeta do-file in the do-file editor. If your form has a select_multiple field, the do-file will have a section that begins with the comment:

* Rename any variable names that are difficult for -split-.

You should copy and paste the code from the help file into the do-file, immediately before the section that begins with that comment. (Let me know if your form doesn't have a select_multiple field.) Once you have finished modifying the do-file, run it again in order to recreate the datasets.

If you don't feel comfortable modifying the do-file, Stata has built-in ways to remove prefixes from variable names: see help rename for more information.

Hope that helps!

Hi Matthew,

This worked, save for the multiple-choice options that were split by briefcase during import. Is this normal behaviour? Nonetheless, this has saved me a whole lot of work.
Once again, thanks loads. Cheers :slight_smile:

Hi @Musinguzi_Polycarp! odkmeta will split select_multiple fields itself, so you should turn off "Split select multiples" when exporting from ODK Briefcase.

Thanks a lot, Matthew. Much appreciated :clap: :clap: :clap:

when I run the do file it splits the multiple choices answers but the main option is dropped, Is there a way not to drop the original multiple choice after the split.

I will recommend using osk2stata is easier to use.

I will say that try this one and you will be able to get your STATA.do file in minutes.

Best,
Narendra

Thank you. I am going to try that and feedback.