Apr 2, 2014

How to replace line break with comma in text pad

A friend of mine asked me how to search and replace new line characters on TextPad editor. Sometimes we want to form a comma seperated values of all data in a column. It takes time to edit this manually and form the list.

Fortunately, TextPad supports "regular expressions" using which may come handy on several occasions. It is fairly simple as long as you know that "\n" means a new line in the world of computers, and the awareness that TextPad supports Regular Expressions syntax.

Here is an example document with random words:
document with words in multiple lines
And you fire the replace operation by hitting F8.
Find What: type \n
Replace with: type , (or whatever character you need)
Check "Regular Expression" box before you search / replace
And it will be all merged on to the same line. This looks simple while for an user trying to do this on a several hundred line file, would give big sigh of relief after learning this.
Final result after the replace operation

4 comments:

  1. Hi. I want to do almost the opposite. I have a large volume of data, and want to put each on a separate line so I can copy it into excel and get a count of each word using pivot. I was told I could do this with \n, but I don't know how to set it up.

    ReplyDelete
  2. @It's a wonderful life - Yes you can definitely use it. Is there any delimiter to separate your large volume of text? in TextPad, you need to replace that character, for example - a "," with "\n". Then you will notice that this chunk is replaced.

    ReplyDelete
  3. thanks for this neat tip, saved me a lot of time!

    ReplyDelete

You may also like these writeups

Related Posts with Thumbnails