Remove blank lines in CSV file with GEANY

Zhenyu

I've a file which holds empty lines, which I'd like to remove.

Is there a way to remove empty lines from Geany?

Note: I don't want to use another editor because I'm afraid it will add or change my csv format/encoding as I need to import these csv files as the format / encoding it is now.

enter image description here

Yaron

If you insist to perform it inside geany editor - You can use geany lineoperations plugin which add the Remove Empty Lines feature to geany


A simpler way might be - to treat the file as a regular text file, and remove the empty lines using command-line tools (e.g. sed)

Here You can see several examples how to remove empty line from a text file.

Using sed:

sed '/^$/d' <input-file>

To delete all empty lines from a file called /tmp/data.txt, enter:

sed '/^$/d' /tmp/data.txt

To store output to another file use redirection operator:

sed '/^$/d' /tmp/data.txt > /tmp/output.txt

Note: Using sed to remove empty lines shouldn't change anything with the non-empty lines in file

Note: In order to modify the file in place you should use sed -i flag:

sed -i '/^$/d' <input-file>

Example:

The original text file:

$ cat in.txt 
This is a test

Linux rulez


Windows sucks
Ubuntu is good server disro

sed output when running on the file:

$ sed  '/^$/d' in.txt 
This is a test
Linux rulez
Windows sucks
Ubuntu is good server disro

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related