I have a survey with 5 repeat groups. I am trying to use ODK meta to merge the main data with the repeat group data. However, the generated ODK Do-File does not run the merge and gives error during the assetion of the merge.
assert `merge' != 2
"Assertion is flase"
I think the problem arises because PARENT KEY and KEY are different, but I am unable to solve/find this on the code.
I have not found any similar post. Hope someone has encountered this problem before and can help solving the problem.
This isn't an issue I've seen before. That error should be issued only if there is a row of a repeat group .csv file that does not correspond to any row of the parent .csv file. (Like you said, the issue is a mismatch between PARENT_KEY and KEY.) For example, this error could be issued if there were a row in a repeat group .csv file that did not belong to any of the submissions in the main .csv file (something that shouldn't happen).
What steps did you use to export the .csv files? Could it be that the .csv files were not all exported at the same time? If you re-export the .csv files using ODK Briefcase, do you still see the error?
I have only one survey, with 5 different repeat groups.
I used Briefcase to export the data into a .csv file. I got 6 files. One parent file and 5 subgroup files.
Right after the export, we can already see that the PARENT_KEY and KEY are different in the .csv files. And this persist until the end of the Do-File. See next lines:
Adding more information that could help understanding the problem:
In my original survey, there were some subgroups with no information because it happened that nobody reported animals of that type. Once I used the ODK-created Do-File, an error pop up because some of the subgroup files were empty. I then proceeded to create a test submission by myself, where all subgroups had dummy information and run the do-file. This way, there were no problems with subgroups having no information, but still problems merging the PARENT and SUBGROUP information.
I solved the merging problem by adding some code-lines where I only keep the first 41 characters of the PARENT and KEY. So that in the example above, the last part is deleted from the subgroup key. I think this is a really ad-hoc and messy correction and would like to know if there is any other way.
Removing manually the /consented[1]/illhistory[1]/health_service_utilization[1] then it works.
Another modification that I needed to do is renaming the child csv file as the do file doesn't generate it as it comes from Briefcase, but with a different name.
@Francisco_Carballo, @aurdipas, have you been able to use odkmeta successfully in the past? Can you tell whether these issues have only recently started occuring?
It'd be quite useful if you're able to upload an example form that demonstrates these two issues (the merge error and the filename issue). From there, I'll see if I can figure out what the source of the issues is.
We're still investigating, but one possibility is that this is related to changes made for Briefcase version 1.11.0. (The current version of Briefcase is 1.12.0.) I've created a GitHub issue about PARENT_KEY and one about filenames.
While those discussions are ongoing, one option is to use the latest version of Briefcase before 1.11.0, which is 1.10.1. When I use that version, the odkmeta do-file doesn't issue any error messages about KEY. The filenames will still differ slightly — Briefcase 1.10.1 exports filenames with underscores, while the odkmeta do-file uses hyphens — but otherwise they should be the same.
It is the first time using ODK meta, I do not know when they ocurred first.
Regarding file names, in my case the names differ more than only underscores. In the repeat group files, an extra word is included in the Do-File (namely the name of the group), while the file exported from Briefcase does not include the name of the group.
Do you still see this if you export the CSV files using Briefcase 1.10.1? If you use that version of Briefcase, I think the only difference should be whether the filenames include hyphens or underscores.
Thank you for the quick release, @ggalmazor! @Francisco_Carballo, @aurdipas, this should resolve the two issues you were seeing. Filenames are also exported with hyphens between group names, not underscores, which means that the odkmeta do-file should work without you having to modify filenames.
Thanks for the quick fix. File names are good now, and PARENT_KEY and KEY match in the parent and child files.
However, okdmeta still does not run properly. In this case, a problem with the device_id is issued:
device_id
char device_iddevice_id[Odk_name] device_id
ERROR: variable device_iddevice_id not found
I think it could be related to the changes in hyphens/underscores. I am sure there are easy solutions to it, by tailoring the code to my needs. Unfortunately I have never worked with some of the commands used in the Do-File that "odkmeta" exports.
Thanks for reporting this, @Francisco_Carballo. Other than having to modify filenames, were you able to run the odkmeta do-file successfully for exports from Briefcase 1.10.1? Or is this error message also issued for exports from Briefcase 1.10.1?
The latest version of Briefcase changed the delimiter in filenames back from an underscore to a hyphen, but it did not change the delimiter in column headers, which I believe has always been a hyphen. The Stata insheet command removes hyphens from column headers, but odkmeta knows to account for that behavior.
It'd be very helpful if you could share the form you're using or another form that results in the same error message. From there, I can do more investigation into the error message.
I have to note that this error is only issued when I generate a new odkmeta do-file on my survey and try to run it.. So it might be more related to odkmeta than to a Briefcase version. To be honest, I am a bit confused now.
The code generated by "odkmeta" is somehow different than the code I used couple of days ago when I reported the first issue. I do not know if something has been changed in the user-written odkmeta command, but I am unable to export exactly the same Do-File as I had it before. I did modify something manually myself, but not in that chunk of the code. Anyway, a new-generated code is issuing the error, so it should be taken care of.
As for the questions:
The error is also issued using Briefcase v1.10.1.
I have privately sent you a copy of the form I am using. Please, let me know if there is anything else I can help with.
Thanks for sharing your form, @Francisco_Carballo! When I ran odkmeta for the form and ran the resulting do-file, no error message was issued. I also don't see this command in the do-file, which you mentioned above:
char device_iddevice_id[Odk_name] device_id
Instead I see:
char device_id[Odk_name] device_id
@ggalmazor released a new version of Briefcase last week (version 1.12.1), but there's been no recent update to odkmeta.
I would first try re-exporting the survey and choices sheets of your XLSForm and rerunning odkmeta using those. It seems odd that you can't reproduce the do-file that you originally generated.
There's been no recent update to odkmeta, but you can check that you have the correct version by typing which odkmeta in Stata. You should see a file path followed by:
I collected my data and now need help merging it using ODK Meta in preparation for analysis in stata. The data has two repeat groups (each with several questions) and on exporting it using briefcase, i get three three separate csv files i.e the parent file and the two (one for each repeat group). When I have had one csv file, the following command has helped with minimal challenges
odkmeta using import.do, csv("ODKexample.csv") survey("survey.csv") choices("choices.csv")
Now that I have three files which need to be merged together into one single dataset, which command do I use or how do I mordify the command above to get me what I need. Friends, I would like to put a disclaimer that I am not tech-savvy and would appreciate keeping the guidelines really simple. Much appreciated