comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Cut down a big file into several files based on its a column.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Cut down a big file into several files based on its a column. [message #53007] Wed, 14 March 2007 02:46 Go to next message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Mar 14, 1:22 am, "DirtyHarry" <kim20...@gmail.com> wrote:
> Good day, everyone! (I wrote 'Good morning', but maybe it is not
> morning for others. anyway) I would like to slice a big data file
> into several files based on its a column, but it was not successful
> yet. Please give me some suggestions.
>
> The contents of my original data file are...
>
> 90|2000|1|1|95|95|95|95|95|96|95|95|94|93|93|93|94|94|94|95| 95|93|91|
> 90|94|95|96|95|
> 90|2000|1|2|96|95|94|96|93|93|76|74|76|81|85|84|76|53|43|40| 39|41|33|
> 33|32|32|33|35|
> 90|2000|1|3|35|34|38|35|29|28|30|29|26|23|25|22|22|30|29|24| 23|24|36|
> 31|34|39|31|34|
> .
> .
> .
>
> This is a 2-dim array, I named this array as 'data(*, *)'.
>
> What I want to do now is to slice this file into 6 files based on the
> information in 2nd column, ( data(1,*) ). This column includes year
> info, and the values are from 2000 to 2006.

use your shell (bash) and awk:

for year in 2000 2001 2002 2003 2004 2005
do
awk -F\| -v year=$year '{if($2==year){print $0}}' < hum.txt > HumNWS_
$year.txt
done

This assumes a unix-like system, and just copies the lines that match
the year to a new file. Seems earier to me than using IDL.

Maarten
Re: Cut down a big file into several files based on its a column. [message #53065 is a reply to message #53007] Fri, 16 March 2007 02:46 Go to previous message
kim20026 is currently offline  kim20026
Messages: 54
Registered: November 2006
Member
Thanks, Maarten... but... T.T

Is there any way to do this in Windows version of IDL?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: google summer of code
Next Topic: Change in Map_Contintent behavior?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:36:34 PDT 2025

Total time taken to generate the page: 0.00274 seconds