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 (W/O delimiters) into several... but I still don't understand
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Cut down a big file (W/O delimiters) into several... but I still don't understand [message #53120 is a reply to message #53119] Tue, 20 March 2007 02:16 Go to previous message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
DirtyHarry wrote:

> Last week I posted a question with almost same topic. I would like to
> slice a big file into several accoding to one of its row. I found
> there is some 'delimiter' problem that I cannot solve at this point.
> So I deleted them through making another simple IDL code and made a
> new data file, but still I got stuck in cutting it down.
>
> This is a part of my data file.
> file: 'HumNWS1.txt' (data(28, 164094))
>
> 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
> .
> .
> .
>
>
> To divide this, I set up a source code like this...
>
>
> ------------------------------------
> pro hum_year
>
> ;
>
************************************************************ ***********************
>
> ; 1. Read file and set the initial value of variables and arrays.
> file = 'HumNWS1.txt'
> ndata=file_lines(file)
> data=intarr(28, ndata)
>
> close, /all
>
> ; 2. Prepare for new text files.
> openw,1,'HuNWS_2000.txt'
> openw,2,'HuNWS_2001.txt'
> openw,3,'HuNWS_2002.txt'
> openw,4,'HuNWS_2003.txt'
> openw,5,'HuNWS_2004.txt'
> openw,6,'HuNWS_2005.txt'
>
>
> ; 3. Read data and write them on the desgnated files.
>
> for t=0L,ndata-1 do begin
> case data(1L,t) of
> 2000:printf,1,format='(28i6)' , data[*,t]
> 2001:printf,2,format='(28i6)' , data[*,t]
> 2002:printf,3,format='(28i6)' , data[*,t]
> 2003:printf,4,format='(28i6)' , data[*,t]
> 2004:printf,5,format='(28i6)' , data[*,t]
> 2005:printf,6,format='(28i6)' , data[*,t]
> else:
> endcase
> endfor
>
> ; 4. close all files.
> close, /all
>
> print, 'Process is done!'
>
> end
> ----------------------------
> There was no problem in compiling. When I ran this file after
> compilation, there were no error messages, either. However, after I
> checked those new files (i.e. 'HuNWS_2000.txt'), I found there were no
> data in there... I don't understand why this happens. What's wrong in
> my case statement... ? Please give me some suggestions... thanks.


Nowhere in that code do you read the data from the file.

It helps if you do that, so that the data() array actually has some contents.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
[Message index]
 
Read Message
Read Message
Previous Topic: Re: random musings
Next Topic: Widget Tree Insensitivity / Dialog Box

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

Current Time: Tue Dec 02 18:21:20 PST 2025

Total time taken to generate the page: 0.24060 seconds