Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields with line breaks \n #100

Closed
Startouf opened this issue May 20, 2016 · 1 comment
Closed

Fields with line breaks \n #100

Startouf opened this issue May 20, 2016 · 1 comment

Comments

@Startouf
Copy link

I need to export text fields that contain several line breaks \n. They are not escaped and when transforming to csv, they generate extra rows.

model Profile
  field :description
  # Sample description
  # "Hello,\n I'm here to destroy your CSV export 3:D"
end

Is there a way to escape them ? Or should I just define a description_escaped method that would substitute those \n by another separator ?

@eitoball
Copy link
Contributor

Passing force_quotes: true when you call to_comma might solve issue. According RFC 4180,

 6.  Fields containing line breaks (CRLF), double quotes, and commas
     should be enclosed in double-quotes.  For example:

     "aaa","b CRLF
     bb","ccc" CRLF
     zzz,yyy,xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants