Bug 236125

Summary: Import skips empty CSV cells
Product: [Applications] kaddressbook Reporter: Ken West <ken.west>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: tokoe
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Ken West 2010-05-03 08:57:25 UTC
Version:            (using KDE 4.4.2)
OS:                Linux
Installed from:    Ubuntu Packages

The import CSV function skips empty cells.

For example, with the following CSV file ...

"Email (preferred)","Business Phone","Formatted Name"
"fred@gmail.com","555 12345","Fred"
"wilma@gmail.com",,"Wilma"

... the business phone for Wilma is empty (represented by a zero-length string).

If this is imported into kaddressbook, using the mapping suggested by the first line of the CSV file, and ignoring the first line: a contact is created for Fred with phone and email as expected; a contact is created for Wilma, but the name is "" and the phone is "Wilma".

It's interpreted as if the last line was ...

"wilma@gmail.com","Wilma"

... that is, the second, empty field is ignored.

Changing the last line to ...

"wilma@gmail.com","","Wilma"

... produces the desired behaviour.
Comment 1 Tobias Koenig 2010-05-07 11:45:22 UTC
Hej Ken,

this bug has been fixed lately by a rewrite of the CSV parser.
However we can't backport this change to 4.4 branch, so you have to
wait for 4.5.

Ciao,
Tobias
Comment 2 Ken West 2010-05-08 04:20:18 UTC
Thanks, Tobias!

Until 4.5 hits the streets, the following shell command will work around the issue by translating NULL fields into empty string fields ('input-null.csv' and 'input-empty.csv' respectively) ...

sed "s/,,/,\"\",/g" input-null.csv | sed "s/,,/,\"\",/g" - > input-empty.csv

Ken