In the Settings of CSV file format it is already possible to replace newlines in rendered fields.
But with this option you can only replace "real" line feeds (\n). Because in Windows it is normal that a linefeed consists of a Carriage Return plus a Linefeed (\r\n) it would be nice if you could choose what to replace.
Please find attached a patch (against the last dev-version) to enhance the functionality accordingly.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | linefeeds_as_replacements-1957114-15.patch | 1.22 KB | vasike |
| #8 | views_data_export-allow_carriage_return-1957114-8.patch | 6.33 KB | arnested |
Comments
Comment #1
TWD commentedHas this been committed to 7.x-3.0-beta6 ?
I am still having this issue.
Comment #2
steven jones commentedThis needs some tests to make sure that the patch does what it should, and the patch in the OP was also diffed in the wrong direction, i.e. you have to apply the reverse to get it to apply.
Comment #3
nemethf commentedI made a patch based on smitty's one. It replaces all the new line combinations ('\r\n' or '\n' or '\n') by choosing the second option on the style settings. It is needed for us, because text field values in our db are inhomogeneous regarding the new lines. Test cases are included.
Comment #4
nemethf commentedComment #5
arnested commentedYou need change all the strings containing \n, \r\n, and \r to use double quotes instead of single quotes.
Otherwise you'll just replace literal occurrences of \n, \r\n, and \r. That is why the tests also succeed.
Change that and I'll be ready to RTBC :-)
Comment #6
arnested commentedI made the changes mentioned in #5.
Comment #8
arnested commentedOoops. The test case wasn't fixed correctly.
New patch added.
Comment #9
arnested commentedComment #10
nemethf commentedThanks Arne, for pointing to the quotation bug. I tested the corrected patch. Works well with test data.
Comment #11
ikeigenwijs commentedPatch applied directly.
Works as advertised this was exactly what we needed.
We have mixed environments Windows and Linux so \n and \n\r are used.
Comment #13
steven jones commentedThanks everyone for the patch and the work, fixed in 7.x-3.x
Comment #15
vasikeit seems the replacement doesn't work properly for special characters: as \n
For example there could be both Carriage Return plus Linefeed ("\r\n") and single Linefeed ("\n") that we want to replace with single Linefeed ("\n")
With the current code we'll get the '\n' string instead of single Linefeed ("\n")
Here is patch that could help for this kind of replacements.
Comment #16
steven jones commentedSorry for the lack of attention to your issue, please accept my apologies.
Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.
As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.
If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.
Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)