Note that there are some explanatory texts on larger screens.

plurals
  1. POAWK - loop through a large CSV file and print a new CSV containing records that pass criteria
    primarykey
    data
    text
    <p>I am trying to parse a large CSV (about 90 MB) that has a header section (130 rows, single column). Line 131 is the column header that has names for individual column (20 columns in total).</p> <p>I don't need to parse the first 9 columns, the data beginning from column #10 through colum#20 are in the following format (reformatted as column for easier view, but each row below is actually in an individual column in the CSV)</p> <p>0/0:<strong>3,0</strong>:9:0,9,90</p> <p>./.</p> <p>0/1:<strong>6,3</strong>:49:73,0,111</p> <p>0/1:<strong>13,3</strong>:99:103,0,254</p> <p>0/1:<strong>6,6</strong>:45:56,3,124</p> <p>0/1:<strong>2,2</strong>:34:43,0,51</p> <p>0/1:<strong>80,0</strong>:87:252,5,1882</p> <p>0/1:<strong>25,12</strong>:99:139,286,3281</p> <p>./.</p> <p>0/1:<strong>6,8</strong>:64:64,0,130</p> <p>0/1:<strong>4,5</strong>:65:109,0,114</p> <p>Take this "0/0:<strong>3,0</strong>:9:0,9,90" as an example, the criteria is: if the two numbers (3,0) as highlighted add up to >=20 AND the second number (0) is greater or equal to 10, then print it out to new CSV. If does not pass the criteria, just print "./." in the new CSV. The cells that have "./." already will remain "./." in the new CSV. </p> <p>I have asked a part of the question in this thread <a href="https://stackoverflow.com/questions/18244092/use-awk-to-process-a-csv-tab-delimited-line-by-line">use awk to process a csv (tab delimited) line by line</a> and, thanks to Kent, I now know how to apply the criteria to a single cell, but I need to loop through 10 columns and apply the same criteria. Below is what I have come up with, but apparently, I need more help with finishing this. Any help/suggestion will be appreciated.</p> <pre><code>BEGIN { -F'\t'; -v OFS='\t' for (i=10; i&lt;=20; i++) { t=$i; split(t,a,/[:,]/)}(a[2]+a[3])&gt;=20 &amp;&amp; a[3]&gt;=10 } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload