Hello,
Thanks for such a great module. I am having a problem importing any content that includes quotes (single or double). What is the correct escape sequence (e.g. \') to get around these problems? If there are no escape sequences, what would be the best way to get around the problem?

Thanks

Comments

goodeit’s picture

Status: Active » Fixed

I'm not sure this qualifies as "fixed", but maybe it will help someone:

what I did was use OpenOffice to export my CSV as TAB delimited, with no field delimiters (e.g. not ' or "). Then node_import successfully imports standard quotes and single quotes just fine.
-------------
Example File:
Product Price SKU DESCRIPTION
Car 4000 REDCAR This car's on fire!
Truck 6000 BLUETRUCK This car is "blue!"

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jako0013’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

I have this issue as well and it is not clear from the code how to fix this. Does anyone have an idea or is the module author out there still?

goodeit’s picture

Priority: Normal » Critical

Looking at this again, I was mistaken -- it appears that double quotes (") still do not import correctly, even if the Text qualifier symbol is set to blank or a different character.

Changing all double quotes to & quot; (no space - html markup) works fine for body fields, but if there are any titles with double quotes, the text "& quot;" shows in the titles.

EDIT: whoops html markup fix

goodeit’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

OK, I think I have figured this out. Per the node_import code, the default escape sequence is \[character] e.g. \" . The reason it wasn't working for me was that OpenOffice was automatically converting my double quotes into either right or left quotes... which then broke node_import. This isn't necessarily a node_import bug so much as something its not designed to handle.

To turn off automatic quote changes in OpenOffice, go to Tools -> AutoCorrect -> Custom Quotes and uncheck "double quotes".

Make sure you check your CSV with another program (I recommend Notepad++) because OpenOffice seems to be doing other weird things to my CSV, such as adding in an extra set of quotes.

I believe this answers my original question, so I'm going to close this. If anyone else has another problem, feel free to reopen.

neclimdul’s picture

Category: support » bug
Priority: Critical » Normal
Status: Closed (fixed) » Active

Actually I think this is a bug. Doubled quote escaping is an excepted behavior in both MS Office and OpenOffice and is defined in RFC 4180.

7. If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:

"aaa","b""bb","ccc"

This is causing a problem with Views Bonus built CSV's because it follows this pattern.
#205741: [PATCH] Can an CSV Export Preserve Links, Formatting, Etc. in Fields?

rkendall’s picture

I'm having a problem with this as well, as per #6, although I am using user_import with content_profile (which also requires node import).

I noticed that user import and node import seem to have different methods. user_import uses PHP's fgetcsv for which this is a known problem: http://bugs.php.net/bug.php?id=50686

Isn't there a proven PHP CSV parser that can be incorporated to fully support CSV formats? Maybe a separate file parser import/export API module is needed?

cyberwolf’s picture

Subscribing