Group Abstract Group Abstract

Message Boards Message Boards

Find and replace carriage returns in data set

Posted 10 years ago
POSTED BY: Peter Nilsson
2 Replies

A carriage return is often found (with XLS) als the character \n (sometimes txt files have \r) When you import the test.xls with

data=Flatten[ Import["test.xls"],1]
data//Grid

enter image description here

Now if you want the second column that contains text with some \n characters you can select the row and delete all the carriage returns with

Map[StringReplace[#, "\n" -> ""] &, data[[All, 2]]]

{row 1And here is some text.And some more,row 2And here is some text.And some more,row 3And here is some text.And some more,row 4And here is some text.And some more,row 5And here is some text.And some more,row 6And here is some text.And some more}

Hope this helps.

Attachments:
POSTED BY: l van Veen

Hi Peter,

it would be very useful to have an example dataset. It is difficult for me to reproduce the problem.

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard