Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a different from someone else's similarly-titled question. Neither Excel nor OpenOffice allow users to specify line delimiters, so I'm trying to replace semi-colons with line breaks. How do I edit the code of a text file?

In Notepad I tried replace ; with /n. I didn't think it would work; and it didn't. My long single-line txt/~csv file is crying: Help!

share|improve this question

migrated from stackoverflow.com Jul 13 '11 at 19:19

This question came from our site for professional and enthusiast programmers.

    
So you dont want to do this programmatically? But you want to take a file with breaks indicated with semi-colons and change those semi colons to actual line breaks through find and replace? –  noShowP Jul 13 '11 at 13:11

4 Answers 4

Using sed:

sed -e 's/:/\n/g' foo.txt
share|improve this answer
    
Is that a typo that you inserted a colon instead of a semi colon? Also that -e is not necessary in this case. –  Bobby Aug 23 '13 at 12:20

I assume that if you have Excel, you have Word....

You can add line breaks from the Find/Replace function in Word 2010 - make your CSV a .txt and go to town. Under Find/Replace click the "More >>" button and then the special drop down box to insert a line break as a replacement for ":"

You can also accomplish this with NoteTab; you would run a replace-all command, replacing ";" by \r\n -- but be sure to check the "regular expression" box.

"\" is a prefix to indicate regular expression codes and special characters. "\r" is a carriage return and "\n" is a line-feed; the pair forms a Windows newline.

share|improve this answer

The best popular editor for this kind of task is vim. You'll have some learning to do, so I won't get specific about the commands. It's an essential tool if you mess around with text files much.

share|improve this answer

Using a Programmer's Notepad

  1. Find what: <br />
  2. Replace with: \r
  3. Click Replace all

Then repeat

  1. Find what: <p>
  2. Replace with: \r
  3. Click Replace all

Then repeat

  1. Find what: </p>
  2. Replace with: \r
  3. Click Replace all
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.