In the JSON commas were there in the remarks column text so when we execute mongo command ,in the csv file ,remarks was going to the multiple cells.Can we restrict whole remarks column should be in one cell?
mongo dbEntityDB dbEntity.js > out.csv
db.dbEntity.insertOne(
{
"employee": {
"employeeId": "46363366",
"name": "wrwr",
"remarks": "abcd,efgh"
}
}
)
dbEntity.js
************
print("employeeId,name,remarks");
cursor=db.dbEntity.find();
let out="";
while(cursor.hasNext()){
jsonobj=cursor.next();
employeeId = jsonobj.employee.employeeId;
name = jsonobj.employee.name;
remarks = jsonobj.employee.remarks;
out =out+ employeeId +","+name +","+customerName+","+remarks+"\n";
};
print(out)