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.

Comments

TWD’s picture

Has this been committed to 7.x-3.0-beta6 ?

I am still having this issue.

steven jones’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This 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.

nemethf’s picture

Issue summary: View changes
StatusFileSize
new5.6 KB

I 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.

nemethf’s picture

Status: Needs work » Needs review
arnested’s picture

Status: Needs review » Needs work

You 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 :-)

arnested’s picture

Status: Needs work » Needs review
StatusFileSize
new6.32 KB

I made the changes mentioned in #5.

Status: Needs review » Needs work

The last submitted patch, 6: views_data_export-allow_carriage_return-1957114-6.patch, failed testing.

arnested’s picture

Status: Needs work » Needs review
StatusFileSize
new6.33 KB

Ooops. The test case wasn't fixed correctly.

New patch added.

arnested’s picture

Title: Allow Carriage Rerturn to be replaced » Allow Carriage Return to be replaced
nemethf’s picture

Thanks Arne, for pointing to the quotation bug. I tested the corrected patch. Works well with test data.

ikeigenwijs’s picture

Status: Needs review » Reviewed & tested by the community

Patch 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.

  • Steven Jones committed 9b840da on 7.x-3.x
    Issue #1957114 by arnested, nemethf, smitty, ikeigenwijs: Added allow...
steven jones’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

Thanks everyone for the patch and the work, fixed in 7.x-3.x

Status: Fixed » Closed (fixed)

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

vasike’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.22 KB

it 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.

steven jones’s picture

Status: Needs review » Closed (won't fix)

Sorry 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 :)