I have the below json format of document in my collection in mongodb.Now i need to export this data into csv with only specified fields and i dont want frequency_serving "Never" value object(Under VFoodDetails Array)in csv.What i tried the below command
-c FrequencyQuestionForm --type=csv --fields data.formList.IdentificationDetails.Group_Id,data.formList.IdentificationDetails.Study_Name -q '{"data.formList.IdentificationDetails.Study_Id":"1"}' --out D:/MongoDBReports/Book1.csv
it throws an error like this
"too many positional arguments: [dbmongo 27017 FormDataBase FrequencyQuestionForm 'data.formList.0.IdentificationDetails.0.Group_ Id,data.formList.0.IdentificationDetails.0.Study_Name'] 2018-02-12T17:37:58.012+0530 try 'mongoexport --help' for more information"
[
{
"_id": "5a6026e29cbcdc48083dae1a",
"data": {
"formList": [
{
"IdentificationDetails": [
{
"Status": "Data Entry Completed",
"Form_Id": 1,
"Interviewer_Name": "NAGARAJ.P",
"Group_Id": 9,
"Study_Id": "1",
"Study_Name": "INDIAB",
"Created_Emp_Id": "1",
"Form_Name": "Food Frequency Questionnarie",
"Visit_No": "1",
"Volunteer_Id": "R270116",
"Interview_Date": "2009-10-10T00:00:00Z",
"Volunteer_Name": "RAJENDRA PAWAR"
}
]
},
{
"VFoodDetails": [
{
"Portion_Size": 15,
"Serving_Size": "0",
"Food_Id": 737,
"Value": "0",
"Portion_Tool": 18,
"Volunteer_Id": "R270116",
"Meal_Session": 121,
"Frequency_Serving": "Daily"
},
{
"Portion_Size": 168,
"Serving_Size": "0",
"Food_Id": 740,
"Value": "0",
"Portion_Tool": 177,
"Volunteer_Id": "R270116",
"Meal_Session": 121,
"Frequency_Serving": "Never"
}
]
}
]
}
},
{
"_id": "5a6026e29cbcdc46783dae1a",
"data": {
"formList": [
{
"IdentificationDetails": [
{
"Status": "Data Entry Completed",
"Form_Id": 1,
"Interviewer_Name": "NAGARAJ.P",
"Group_Id": 9,
"Study_Id": "1",
"Study_Name": "INDIAB",
"Created_Emp_Id": "1",
"Form_Name": "Food Frequency Questionnarie",
"Visit_No": "1",
"Volunteer_Id": "R270176",
"Interview_Date": "2009-10-10T00:00:00Z",
"Volunteer_Name": "KUMARAN PAWAR"
}
]
},
{
"VFoodDetails": [
{
"Portion_Size": 15,
"Serving_Size": "0",
"Food_Id": 737,
"Value": "0",
"Portion_Tool": 18,
"Volunteer_Id": "R270176",
"Meal_Session": 121,
"Frequency_Serving": "Never"
},
{
"Portion_Size": 168,
"Serving_Size": "0",
"Food_Id": 740,
"Value": "0",
"Portion_Tool": 177,
"Volunteer_Id": "R270176",
"Meal_Session": 121,
"Frequency_Serving": "Weekly"
}
]
}
]
}
}
]