The modern solution for problems like these is a script language like Perl or Python.<br><br>In Python a simple script for working with columns of data might like like this:<br><br>fin = open(infile)<br>for record in fin:<br>
&nbsp;&nbsp;&nbsp; fields = rec.split()&nbsp;&nbsp; # this part splits the fields on white space<br>&nbsp;&nbsp;&nbsp; date = fields[0]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # pick the fields you want<br>&nbsp;&nbsp;&nbsp; time = fields[1]<br><br>&nbsp;&nbsp;&nbsp; ...<br><br>&nbsp;&nbsp;&nbsp; value2 = fields[9]<br><br>&nbsp;&nbsp; print &quot;%f %f %f&quot; % (date, time, value2)&nbsp;&nbsp; # print them to stdout or write to a file
<br><br><br>run the script and capture the output to a file<br>python script.py &gt; bigfile.txt<br><br>I find cut, paste, sed work will for quick jobs (and they would work in your case). But as soon as I need to look up the documentation on sed I have usually reached the point where a Python script would be easier to impliment. For that reason, I never use awk any more.
<br><br>My 2 cents,<br><br>David<br><br>&nbsp;<br><br><br><br><br><div><span class="gmail_quote">On 8/7/06, <b class="gmail_sendername">maning sambale</b> &lt;<a href="mailto:emmanuel.sambale@gmail.com">emmanuel.sambale@gmail.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi!<br><br>I have a number of ascii files downloaded from ASTR fire project from
<br>the ESA Ionia showing monthly fire incidences from 1996-2006.&nbsp;&nbsp;I<br>intend to combine all these files, remove unwanted columns and get the<br>records from my current region/study area only. All records combined<br>is 929,155 records!&nbsp;&nbsp;My guess is I need to use the cat, cut, awk
<br>commands.<br><br>Challenge: the files have different record formating<br><br>file 1 is like this (take note of the space as the delimiter):<br><br>Date&nbsp;&nbsp; Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lon&nbsp;&nbsp;&nbsp;&nbsp; NDVI&nbsp;&nbsp;Station<br>020201 032428.163
&nbsp;&nbsp;-38.379&nbsp;&nbsp;-66.334 -.-- ESR<br>020201 032428.163&nbsp;&nbsp;-38.375&nbsp;&nbsp;-66.323 -.-- ESR<br>020201 032428.312&nbsp;&nbsp;-38.378&nbsp;&nbsp;-66.359 -.-- ESR<br>020201 032428.312&nbsp;&nbsp;-38.374&nbsp;&nbsp;-66.348 -.-- ESR<br>020201 032428.312&nbsp;&nbsp;-38.371&nbsp;&nbsp;-66.337 -.-- ESR<br>
<br>file 2 looks like this:<br>&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orbit&nbsp;&nbsp;Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lon<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 81704.016&nbsp;&nbsp;&nbsp;&nbsp;19.364&nbsp;&nbsp;-155.103<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 81704.164&nbsp;&nbsp;&nbsp;&nbsp;19.373&nbsp;&nbsp;-155.105<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 
81704.164&nbsp;&nbsp;&nbsp;&nbsp;19.375&nbsp;&nbsp;-155.096<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4385&nbsp;&nbsp;&nbsp;&nbsp;100833.648&nbsp;&nbsp;&nbsp;&nbsp;56.638&nbsp;&nbsp; 161.281<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4386&nbsp;&nbsp;&nbsp;&nbsp;130756.352&nbsp;&nbsp; -20.340&nbsp;&nbsp; 134.099<br><br>I only need the columns for date, time, lat, lon<br><br>Here's what I did:
<br><br>#combine all file (monthly)<br>cat 9904ESA01.FIRE 9905ESA01.FIRE 9906ESA01.FIRE 9907ESA01.FIRE<br>9908ESA01.FIRE ... &gt; test<br><br># cut only desired columns (1_4) delimeiter is spac ' '<br>cut -d' ' -f1 test &gt; 1
<br>cut -d' ' -f2 test &gt; 2<br>cut -d' ' -f3 test &gt; 3<br>cut -d' ' -f4 test &gt; 4<br><br># combine all columns<br>paste 1 2 3 4 &gt; test5<br><br>example output:<br><br>021231 223941.761&nbsp;&nbsp; 11.035&nbsp;&nbsp; -5.016 -.-- ESR<br>
021231 224005.303&nbsp;&nbsp; 12.226&nbsp;&nbsp; -6.243 -.-- ESR<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4380&nbsp;&nbsp;&nbsp;&nbsp; 25934.057&nbsp;&nbsp; -37.022&nbsp;&nbsp; -69.589<br>&nbsp;&nbsp;&nbsp;&nbsp;20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4382&nbsp;&nbsp;&nbsp;&nbsp; 45951.090&nbsp;&nbsp;&nbsp;&nbsp;33.005&nbsp;&nbsp;-110.772<br><br>The problem is for the file example 1, lat and lon columns contain
<br>spaces other than the delimiter example &quot; -38.00&quot; while another is<br>&quot;120.00&quot;&nbsp;&nbsp;In the file2 example, more spaces are there.&nbsp;&nbsp;I think I need<br>to process different file formats separately but how do I solve the
<br>problem for spaces in the lat/lon columns?<br><br>One last question how do I get the records for my current region only?<br><br>north:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20:00:01.49976N<br>south:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5:00:01.499767N<br>west:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 115:00:01.5012E
<br>east:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 130:00:01.501193E<br><br><br>I'm starting to understand awk (reading the gawk manual right now) but<br>may take a while to get do something magical.<br><br>Thanks!<br><br>Maning<br><br>--<br>|---------|----------------------------------------------------------|
<br>| __.-._&nbsp;&nbsp;|&quot;Ohhh. Great warrior. Wars not make one great.&quot; -Yoda&nbsp;&nbsp;&nbsp;&nbsp; |<br>| '-._&quot;7' |&quot;Freedom is still the most radical idea of all&quot; -N.Branden|<br>|&nbsp;&nbsp;/'.-c&nbsp;&nbsp;|Linux registered user #402901, <a href="http://counter.li.org/">
http://counter.li.org/</a>&nbsp;&nbsp;&nbsp;&nbsp; |<br>|&nbsp;&nbsp;|&nbsp;&nbsp;/T&nbsp;&nbsp;|http://esambale.wikispaces.com|<br>| _)_/LI&nbsp;&nbsp;|http://www.geocities.com/esambale/philbiodivmap/philbirds.html&nbsp;&nbsp; |<br>|---------|----------------------------------------------------------|
<br><br>_______________________________________________<br>grassuser mailing list<br><a href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</a><br><a href="http://grass.itc.it/mailman/listinfo/grassuser">http://grass.itc.it/mailman/listinfo/grassuser
</a><br></blockquote></div><br><br clear="all"><br>-- <br>David Finlayson