I exported some data in CSV format that has some line breaks within text fields. I can’t get Excel to handle this correctly. I’d like to just edit the file to remove these line breaks.
A valid record begins with a number. I’ve tried putting \n^([^\d]) in the “Find what” box of Notepad++’s find/replace, to match any line beginning with a non-number and the preceding newline. It matches correctly. In the “replace with” box, I put a space followed by \1 to replace the newline with a space and leave the matched character. However, the replace isn’t working at all, nothing gets changed.
What am I doing wrong?
Sample text:
123,0,1,"This is a single line comment","bob","jim"
124,0,1,"This is a multi line comment w/ newline.
This is the second line of the comment","ted","alfred"
125,0,1,"This is another single line comment","jim","bob"
I want to replace the newline just before “This is the second…” with a space so that the file looks like this:
123,0,1,"This is a single line comment","bob","jim"
124,0,1,"This is a multi line comment w/ newline. This is the second line of the comment","ted","alfred"
125,0,1,"This is another single line comment","jim","bob"
I figured it out. I used
(\n)^(?!\d+,\d+)to match any newline followed by the beginning of a line that’s not followed by at least one number, a comma, and at least one number. In “replace with” I just put a space.