Files
jlengrand.github.io/_posts/2012-05-17-easily-change-file-separator.markdown
Julien Lengrand-Lambert e11060535f Replacing all links with HTTPS
2018-03-17 11:04:40 +01:00

1.2 KiB

layout, status, published, title, author, author_login, author_email, author_url, wordpress_id, wordpress_url, date, categories, tags, comments
layout status published title author author_login author_email author_url wordpress_id wordpress_url date categories tags comments
post publish true Easily change file separator Julien Lengrand-Lambert jlengrand julien@lengrand.fr https://www.lengrand.fr 592 https://www.lengrand.fr/?p=592 2012-05-17 15:37:56.000000000 +02:00
tips
programming
bash
sed
separator
file
csv
awk

You may already have found yourself in front of a huge csv file to be processed. Five minutes after having started working, you realize that you want spaces instead of commas in your file. Only problem, the file is 500 megabytes big.

Do you run Linux ? In this case, your case will be solved in 10 seconds (who said as usual ? :p).

Simply open a console and run this line

{% highlight bash %}

sed -e $"s/,/\ /g" myfile > newfile

{% endhighlight %}

or more generally,

{% highlight bash %}

sed -e $"s/old_separator/new_separator/g" myfile > newfile

{% endhighlight %}

If not, well you may want to think about switching then :)

Thanks to Frafra for the tip ;)