Hi,
I need help to import, with Feeds, a csv containing wysiwyg fields (with html code) using a field separtor "|".

The problem is that some strings in these wysiwyg contains unclosed double quote.
For example : |One "string|two string"|

Here, Feeds thinks that One "string|two string" is an only one field and the separator "|" is not taking into account anymore.
The result is that some content imported contains 50 lines of the csv file (probably until Feeds determines that the quote is finally ended).

So, I tried to escape double quote with double quote (as it seems to be the right way for csv files).
For example : |One ""string|two string""|

This solves the initial problem but now html's tag are break.
For example :
Initial string : <img id="image608" style="margin-right:10px; margin-bottom:10px; float:left;" src ="../path/img.img" alt="" width="269" height="177" /> ...Some text...
Escaped : <img id=""image608"" style=""margin-right:10px; margin-bottom:10px; float:left;"" src =""../path/img.img"" alt="""" width=""269"" height=""177"" /> ...Some text...
After import : <img width="500" height="14" alt=" width=269 height=177 /&gt; ...Some text... left="" float:="" margin-bottom:="" style="margin-right:" id="image608">

Can someone helps me on this issue ?
Thanks a lot !

Comments

megachriz’s picture

Status: Active » Fixed

I would try to solve this problem by, before import, replacing all double quotes by a specific string that isn't present in your document, for example [double-quote] and reverse the replacement after parsing. Replacement after parsing can be done with the "Find replace" plugin provided by Feeds Tamper.
For this solution I assume that the pipe character is'nt used literal in your CSV (not present in the HTML code itself, thus only used as the character to break CSV columns). If, however, the pipe character is used inside the HTML code, you'll have to add double quotes before and after the HTML on each row, to correctly mark the column. Do this after replacing " with [double-quote].

Steps:

  1. Open the CSV file in your editor, replace " with [double-quote].
  2. Install the Feeds Tamper module, also enable the submodule Feeds Tamper Admin UI.
  3. For each mapping where the source from the CSV can contain a double quote, add a Tamper plugin of type "Find replace". Set "Text to find" to [double-quote] and "Text to replace" to ".
  4. Import the CSV file with Feeds.
nixou’s picture

I tried this and it's working very well !

Thanks you very much :)

Status: Fixed » Closed (fixed)

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

pdcarto’s picture

Status: Closed (fixed) » Active

I don't think this issue is fixed. When using fields that are not enclosed by double-quotes, regardless of delimiter, it should not treat any double-quote it encounters as if they are field enclosures. Rather, I think it should either require that the user tell it whether double-quotes are field enclosures, or try to guess, based on adjacency of the quotes to the delimiter, whether a given field is enclosed by quotes, and only if it is, then go looking for the closing quotes.

grahamc’s picture

Status: Active » Closed (fixed)
Related issues: +#1839626: Incorrect handling of quotes when parsing CSV

Closing, as there's another issue (or two) about the CSV parser's quote handling.