Marcello de Sales
unread,Sep 13, 2009, 6:00:51 AM9/13/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
Hello Everyone,
I have generated 1M random items for my experiments using the Java
driver... I tried to use the export to CSV format and had "problems":
1. The _id column has the value "ObjectId(value)" enclosing the
value... I wanted only the "value" to be used...
2. The format of the list of items after trying to export to CSV is
not what I thought (using mongoexport)...
Here's an example of an item generated:
> db.SondeDataContainer.findOne()
{"_id" : ObjectId( "e46f40079365ac4a3f063400") ,
"sensor_ip_address" : "192.168.0.151" , "message_id" : "d8a7e831-
ddd0-4c8e-a152-5bcd9c18ef05" , "transaction_time" : 1252812168025 ,
"fact_time" : 1252812057000 , "data" : {"temperature" : "28.62" ,
"sp_condition" : "179.6" , "condition" : "76.8" , "resistence" :
"378.41" , "salinitude" : "0.09" , "pressure" : "0.86" , "depth" :
"1.125" , "ph" : "2.67" , "pH_mv" : "-50.2" , "odo_sat" : "2.8" ,
"odo_condition" : "65.37" , "turbidity" : "0.2" , "battery" : "7.0"}}
Exported to CSV in the following format with the command: mongoexport
--csv -f "_id,transaction_time,fact_time,data.temperature,
data.sp_condition,data.condition....data.battery"
Here's the output...
_id,transaction_time,fact_time,data
ObjectId( "e46f40070066ac4a00003f00" ),1252812168025,1252812119000,
{ "temperature" : "65.92", "sp_condition" : "70.6", "condition" :
"124.7", "resistence" : "2920.35", "salinitude" : "0.09", "pressure" :
"0.154", "depth" : "0.66", "ph" : "2.4", "pH_mv" : "-61.3",
"odo_sat" : "30.3", "odo_condition" : "18.95", "turbidity" : "0.1",
"battery" : "7.9" }
ObjectId( "e46f40070066ac4a00013f00" ),1252812168025,1252812119000,
{ "temperature" : "36.34", "sp_condition" : "84.1", "condition" :
"170.5", "resistence" : "2199.32", "salinitude" : "0.09", "pressure" :
"1.812", "depth" : "0.684", "ph" : "6.11", "pH_mv" : "-78.9",
"odo_sat" : "66.7", "odo_condition" : "11.27", "turbidity" : "0.3",
"battery" : "1.3" }
I'd like to have the actual names of the columns like
_id, transaction_time, fact_time, data.sp_condition, data.resistence,
data....., data.battery
"e46f40070066ac4a00003f00",1252812168025,1252812119000,65.92,70.6,
"124.7", ..., ...., "7.9"
thanks,
Marcello