[SERVER-3648] Trailing commas are not ignored by mongoimport. Fields with empty values are created Created: 18/Aug/11  Updated: 10/Dec/14  Resolved: 13/Mar/14

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 1.9.2
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Sridhar Nanjundeswaran Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongodb 1.9.2 on OS X 64


Issue Links:
Depends
depends on SERVER-2357 mongoimport should ignore trailing co... Closed
Participants:

 Description   

sridhar-macpro:test sridhar$ cat test.csv
name,location
"Chris","Right here",
"Delta","Right here and here" , , , ,

mongoimport -d test -c test -type csv --file ./test.csv --drop --headerline

> db.test.find()

{ "_id" : ObjectId("4e4d8b1df037a08ef9273a18"), "name" : "Chris", "location" : "Right here", "field2" : "" } { "_id" : ObjectId("4e4d8b1df037a08ef9273a19"), "name" : "Delta", "location" : "Right here and here", "field2" : "", "field3" : "", "field4" : "", "field5" : "" }

 Comments   
Comment by Spencer Brody (Inactive) [ 13/Mar/14 ]

This seems like the right behavior as it adheres to the CSV spec.

Comment by Spencer Brody (Inactive) [ 19/Aug/11 ]

I think the current behavior is better as it conforms to the CSV spec, but a case could made for either stripping all trailing commas or stripping those that introduce additional fields beyond those specified with --fields or in the headerline.

Comment by Eliot Horowitz (Inactive) [ 19/Aug/11 ]

Isn't this correct behavior?

Generated at Thu Feb 08 03:03:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.