Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove or replace LF from CSV file

Tags:

csv

notepad++

eol

I have some huge csv files where sometimes the lines end with LF instead to CRLF, ie:

pippo LF
pluto CRLF

I would have a line like pippo pluto CRLF

I'm trying to use notepad++ under Windows 7 but I'm not able to do that...

like image 304
Antonio Avatar asked Sep 19 '13 07:09

Antonio


People also ask

What is LF in CSV file?

A CSV file contains a set of records separated by a carriage return/line feed (CR/LF) pair (\r\n), or by a line feed (LF) character. Each record contains a set of fields separated by a comma. If the field contains either a comma or a CR/LF, the comma must be escaped with double quotation marks as the delimiter.

How do I find and replace in CSV?

When working with a CSV file it is often necessary to find data contained within and sometimes replace it. Find & Replace is used for just this. You can access it from the Edit > Find & Replace menu or by pressing Ctrl-F on the keyboard.


3 Answers

To do so:

Ctrl+F
Go to "Reaplace" tab
In "Find What" paste: ([^\r])\n
In "Replace with" paste: \1
Choose "Regular expression" in "Search Mode"
Replace All
like image 115
Martin Avatar answered Oct 11 '22 17:10

Martin


In "Edit" menu, choose "Convert line feed" and "Convert to windows format (CRLF).

NB: I'm not quite sure of the labels because I have not an english version of Notepad++.

Notepad++ menus evolve from version to version. In the English version of Notepad++ 6.3.2 from the Edit menu, select EOL Conversions => Windows Format.

like image 35
Toto Avatar answered Oct 11 '22 15:10

Toto


Just replace all the \r with "".

To do so:

  1. Ctrl+F
  2. Go to "Reaplace" tab
  3. In "Find What" paste: \r
  4. In "Replace with" paste: ""
  5. Choose "Extended" in "Search Mode"
  6. Replace All
like image 26
Eugene S Avatar answered Oct 11 '22 15:10

Eugene S