Re: help automating 'read in process' and general automating help [message #62101 is a reply to message #62092] |
Fri, 22 August 2008 20:37  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Aug 22, 9:33 pm, mbwel...@gmail.com wrote:
> Hi all,
>
> I need to read in anywhere from 200 to 36000 ascii files and convert
> them into .sav files. I was looking for some help in running a script
> to do this.
>
> I've been using this method (below), but it is far too time consuming
> with this many files.
>
> ------------------------------------------------------------ ------------------------------------------------------------ -------------------------------------------
> IDL> table = read_ascii('g:\Mars_tectonics\10deg _analysis
> \a6.txt',template=ascii_template('g:\Mars_tectonics\10deg _analysis
> \a6.txt'))
>
> IDL> help,table,/structure
> ** Structure <1229360>, 3 tags, length=300, data length=300, refs=1:
> FIELD1 INT Array[30]
> FIELD2 FLOAT Array[30]
> FIELD3 FLOAT Array[30]
> IDL> a6=fltarr(3,30)
> IDL> a6[0,*]=table.field1
> IDL> a6[1,*]=table.field2
> IDL> a6[2,*]=table.field3
> save,a6,filename='g:\mars_tectonics\10deg _analysis\a6.sav'
> ------------------------------------------------------------ ------------------------------------------------------------ ---------------------------------------------
>
> They'll mostly be of this format and the naming convention is A-R and
> 1-16 (for this smaller iteration).
> This is important: if no file is found, i need it to create an array
> of 0's.
> Eventually, perhaps the end of this week, I'll need to work this
> reading method into my actual computational program, but that's a
> little bit later.
>
> As an aside, does anyone know of a way/program/code that'll automate
> the conversion of dbase files to ASCII? I have a program now that does
> it, but it only does one at a time and adds odd characters that I then
> must go in to manually delete.... Time consuming...
>
> Thanks,
> ~Matt
READCOL in the IDL Astronomy User's library might be useful for
reading them in. And FILE_SEARCH would also be useful for figuring out
if a given file exists or not.
-Jeremy.
|
|
|