<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">AWK!<br>
<br>
Here's an short example of awk with a .csv file from inside a bash
script:<br>
<br>
<font face="Courier New, Courier, monospace"> awk -v
locname="${FILE}" -- '<br>
BEGIN { FS = ",[[:space:]]*" } # Field sep: comma,
arbitrary space<br>
/^[[:space:]]*#/ { next } # Skip comment lines<br>
$4 == locname { print $1; exit }<br>
ENDFILE { print locname } # Only printed if not
exited above<br>
' "$DATADIR/data.csv"</font><br>
<br>
I've never handled multi-line columns, but it shouldn't be two
awfully hard<br>
since all fields are surrounded by quotes.<br>
<br>
AWK is blindingly fast.<br>
<br>
-Ken Jackson<br>
<br>
On 04/28/2016 10:36 AM, Rajiv Gunja wrote:<br>
</div>
<blockquote
cite="mid:CAO33OygRr+rcAvmVCXRsaZEPZ=aCb6WmmAZ0tGy5eX0OVh1jLQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">Hey all,
I am trying to cut down on the amount of manual steps I have
to take editing CSV file - sorting, creating new tabs and
categorising them.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">I googled
and found logparser from MS, could not figure it out - maybe a
mental block towards anything MS. </div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">I saw
that it was possible using python or PHP. So turning to you
guys for advice. Which one works best or is there a different
way?</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">I do not
know Python, but I can learn. PHP, I am very familiar with,
but whichever is efficient and can do a better job, I will use
it.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">Problem: </div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">1. CSV
file has 2000+ rows</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">2. Some
columns are multi-line with \r and \n</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">3. fields
are separated by "," and each data item is between quotes ("
")</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;color:#3333ff">Please
let me know.</div>
<div>
<div class="gmail_signature">
<div dir="ltr">
<div><span
style="color:rgb(51,51,255);font-family:verdana,sans-serif"></span> </div>
<div><span
style="color:rgb(51,51,255);font-family:verdana,sans-serif">-GG</span></div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
CALUG mailing list
<a class="moz-txt-link-abbreviated" href="mailto:CALUG@unknownlamer.org">CALUG@unknownlamer.org</a>
<a class="moz-txt-link-freetext" href="http://lists.unknownlamer.org/listinfo/calug">http://lists.unknownlamer.org/listinfo/calug</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>