importing csv with commas #322

Closed
opened 2025-12-29 16:20:56 +01:00 by adam · 1 comment
Owner

Originally created by @rfdrake on GitHub (Aug 3, 2016).

Site names with a comma cannot be imported. As a workaround for just a handful of sites you can remove the comma and then edit the site to put it back. Unfortunately I've got 166 of them so I may need to do some hacking to workaround it.

I tried escaping the commas with , and tried quoting the columns. Both produced errors.

I'm not very knowledgeable of python but it looks like there is a core csv parser that could be used that supports quoting. I tried making naive changes to replace row.strip().split(',') with csv.reader(row), but I'm not sure how to write a unit test to make sure that would work.

Originally created by @rfdrake on GitHub (Aug 3, 2016). Site names with a comma cannot be imported. As a workaround for just a handful of sites you can remove the comma and then edit the site to put it back. Unfortunately I've got 166 of them so I may need to do some hacking to workaround it. I tried escaping the commas with \, and tried quoting the columns. Both produced errors. I'm not very knowledgeable of python but it looks like there is a core csv parser that could be used that supports quoting. I tried making naive changes to replace row.strip().split(',') with csv.reader(row), but I'm not sure how to write a unit test to make sure that would work.
adam added the type: feature label 2025-12-29 16:20:56 +01:00
adam closed this issue 2025-12-29 16:20:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 3, 2016):

Implemented Python's built-in CSV reader to support double-quoting values. For example:

"New York, NY",new-york-ny,Other stuff

becomes

['New York, NY', 'new-york-ny', 'Other stuff']
@jeremystretch commented on GitHub (Aug 3, 2016): Implemented Python's built-in CSV reader to support double-quoting values. For example: ``` "New York, NY",new-york-ny,Other stuff ``` becomes ``` ['New York, NY', 'new-york-ny', 'Other stuff'] ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#322