I need to use feeds importer to import csv file. But there's single quote in the values like doesn't. Is there anyway to escape the single quote?


  • Do you have problems with single quotes? According to standard no need to escape them. – kalabro Jul 3 '12 at 18:24
  • I don't know if it's because there were some weird characters entered along with the single quote. When I import then, they give me errors. So I took them out and put as does not instead, and it worked out fine. – lusketeer Jul 5 '12 at 12:51
  • @lusketeer: the problem you have is another story. Csv can work well with single quotes, but only within the value (not as a separator). As a separator you need either double quotes or nothing: a,b,c or "a","b",... Regarding the comma as a separator, you can even omit it (but make sure to have no comma at all): a b c – Timo Aug 8 '17 at 9:26

Part of the problem here is that there's no standard specification for CSV.

Added to that, Microsoft does not have much incentive to ensure interoperability between their version of CSV and Drupal's version, and so it is not surprising that they do not offer any (direct) way to encapsulate the contents of cells with single quotes within double quotes, so you've got to do something a bit more complicated if you want Excel to output Drupal-friendly CSV files.

Or, since Drupal is telling you where the problem is, you can do it manually. If you only have a few rows with apostrophes, then that may not be a big deal. If you have a lot of rows in your CSV with apostrophes or single quotes, then you've got a bit of pain.

Alternately, if you've got Python on your machine, or are willing to install it, this python script to add double-quotes to CSVs may work for you, and may be much easier than dealing with Excel macros. It all depends on the languages and language environments you're comfortable with, however.

One might argue that Drupal (or more specifically the Feeds module) should support Microsoft's CSV, and thus handle apostrophes gracefully when not wrapped in double quotes. If you are of this opinion, you may want to file a request with the Feeds project. Since there is no (standard) CSV spec, this can't be considered a bug (AFAIK), but it does seem like a useful feature that they might want to add.

  • The op has another problem not related to CSV, see my comment above. – Timo Aug 8 '17 at 9:31

Just Ensure the CSV value separators are double quotes

  • you mean using double quotes instead of commas? – lusketeer Jul 5 '12 at 12:49
  • "data content", "data's content", "more \"data\" content" – frazras Jul 5 '12 at 21:29
  • is there any shortcut for this in excel? – lusketeer Jul 6 '12 at 13:48

When I have Microsoft Access, I import Excel files into it. Then I export them from Access to a csv file by using an advanced feature to save in UTF-8 format. At the moment I don't have Access so I can't give a better description, but it does work. This takes care of apostrophes and quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.