<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Leylow Lujuo</title>
    <description>The latest articles on DEV Community by Leylow Lujuo (@leyluj).</description>
    <link>https://dev.to/leyluj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F383420%2Fdaef56ee-8852-4f62-96b7-18a187a54b05.jpg</url>
      <title>DEV Community: Leylow Lujuo</title>
      <link>https://dev.to/leyluj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leyluj"/>
    <language>en</language>
    <item>
      <title>Append text in each line in a large CSV (unix style)</title>
      <dc:creator>Leylow Lujuo</dc:creator>
      <pubDate>Wed, 23 Sep 2020 15:33:36 +0000</pubDate>
      <link>https://dev.to/leyluj/append-column-in-each-line-in-a-large-csv-unix-style-53pg</link>
      <guid>https://dev.to/leyluj/append-column-in-each-line-in-a-large-csv-unix-style-53pg</guid>
      <description>&lt;p&gt;Say you have a 10GB csv file and you want to add a text in the end of each line.&lt;/p&gt;

&lt;p&gt;Obviously, opening it in vim work cut it &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;oh will it? ... let me confirm ... I tried and vim crushed :( ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"So, what do we do?" I asked my conscious self while googling and stack-overflow-ing with 10+ tabs opened.&lt;/p&gt;

&lt;p&gt;Viola! one of my stack-overflow tab came through and the answer was &lt;a href="https://en.wikipedia.org/wiki/Sed"&gt;sed&lt;/a&gt; - a stream editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'s/text_to_find/text_to_replace/'&lt;/span&gt; input_file &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output_file
&lt;span class="c"&gt;# example&lt;/span&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'s/\r/|the_text\r/'&lt;/span&gt; big_file.csv &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.csv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Basically, what it does here is;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-r&lt;/code&gt; this option represent extended regular expression&lt;/p&gt;

&lt;p&gt;&lt;code&gt;'s/**\r**/|**the_text\r**/'&lt;/code&gt; the &lt;code&gt;\r&lt;/code&gt; represent EOL, so  replace EOL with &lt;code&gt;the_text&lt;/code&gt; plus EOL(so that the output won't be a single line file)&lt;/p&gt;

&lt;p&gt;The rest i.e... input and output file is self explanatory.&lt;/p&gt;

&lt;p&gt;&lt;del&gt;Writing is exhausting, I'm done.&lt;/del&gt; I have being told to be positive, so i'm scratching this and the line below.&lt;/p&gt;

&lt;p&gt;&lt;del&gt;Now i have to search for a cover image, smh.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;Thanks for your one minute, hopefully I will write again.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>sed</category>
      <category>csv</category>
      <category>file</category>
    </item>
  </channel>
</rss>
