Question

I have a large amount of data in a text file that has been giving me some issues. A lot of the records in the file have line breaks in between the record. For example this is what my data looks like currently:

30670169,           Corvette,   EL-P078675,     EL-P078675, Chevrolet  Corvette C6 Color Matching Millenium Yellow License Plate Frame,     "Made from high-quality billet aluminum, this stylish license frame is custom painted to precisely match the color of your C6 Corvette.

It features an engraved OEM style nameplate. High-gloss finished will never rust.

12"" x 6"" in standard size. Includes color matched screw covers and hardware.

This is a special custom made item. It takes 10-15 business days to ship.

Brand new official licensed product."

This is how is should read:

30670169,           Corvette,   EL-P078675,     EL-P078675, Chevrolet  Corvette C6 Color Matching Millenium Yellow License Plate Frame,     "Made from high-quality billet aluminum, this stylish license frame is custom painted to precisely match the color of your C6 Corvette. It features an engraved OEM style nameplate. High-gloss finished will never rust. 12"" x 6"" in standard size. Includes color matched screw covers and hardware. This is a special custom made item. It takes 10-15 business days to ship. Brand new official licensed product."

I need a method to delete line breaks ONLY if they are surrounded by quotes. Anyone have any ideas?

Was it helpful?

Solution

Try using the Find/Replace function of Notepad++.

Find:

\r(?!\n)

Replace with: (space)

You will need to check the regular expression checkbox:

enter image description here

Try replacing in a few lines first (select the first 80 lines for example) and then replace in selection just to see. If that works, you can proceed with the whole file.

In the above \r will match a CR and \n will match an LF. (?!\n) is a special group that means 'don't match \r if it is followed by \n'.

Note: I think that notepad++ sometimes doesn't do the replace correctly, so if replacing the whole file at once cause issues, try replacing in smaller batches.

I usually use a script to do something like this but I don't think you'd be ready to use a script if you're not used to it :s

OTHER TIPS

You can open the csv file in excel and remove line breaks as shown in this link: http://www.excelblog.ca/remove-line-breaks-from-excel-cell/

Some guidelines

The keyboard shortcut for line breaks

You can do it on one specific column as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top