help automating 'read in process' and general automating help

This is a discussion on help automating 'read in process' and general automating help within the Idl-pvwave forums in Programming Languages category; 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_tectonic s\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 ...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-22-2008, 09:33 PM
mbweller@gmail.com
Guest
 
Default help automating 'read in process' and general automating help

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_tectonic s\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
Reply With Quote
  #2  
Old 08-22-2008, 11:37 PM
Jeremy Bailin
Guest
 
Default Re: help automating 'read in process' and general automating help

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_tectonic s\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.
Reply With Quote
  #3  
Old 08-24-2008, 11:46 PM
mbweller@gmail.com
Guest
 
Default Re: help automating 'read in process' and general automating help

Thanks for the response, I have another question though.

For the

IDL> help,table,/structure
** Structure <1229360>, 3 tags, length=300, data length=300, refs=1:
FIELD1 INT Array[*]
FIELD2 FLOAT Array[*]
FIELD3 FLOAT Array[*]
IDL> a6=fltarr(3,*)


How might I set it up so that the * in the array automaticaly becomes
placed in the fltarr? i.e. if: array[30] then automatically place 30
into fltarr such that fltarr(3,30).
The table structure is throwing me off.

Thanks,
Matt
Reply With Quote
  #4  
Old 08-25-2008, 06:40 AM
Spon
Guest
 
Default Re: help automating 'read in process' and general automating help

On Aug 25, 4:46*am, mbwel...@gmail.com wrote:
> Thanks for the response, I have another question though.
>
> For the
>
> IDL> help,table,/structure
> ** Structure <1229360>, 3 tags, length=300, data length=300, refs=1:
> * *FIELD1 * * * * *INT * * * Array[*]
> * *FIELD2 * * * * *FLOAT * * Array[*]
> * *FIELD3 * * * * *FLOAT * * Array[*]
> IDL> a6=fltarr(3,*)
>
> How might I set it up so that the * in the array automaticaly becomes
> placed in the fltarr? i.e. if: array[30] then automatically place 30
> into fltarr such that fltarr(3,30).
> *The table structure is throwing me off.
>
> Thanks,
> Matt


a6 = Transpose( [ [Table.Field1], [Table.Field2], [Table.Field3] ] )

Search for the array concatenation tutorial on
http://www.dfanning.com

Regards,
Chris
Reply With Quote
  #5  
Old 08-25-2008, 07:03 AM
Spon
Guest
 
Default Re: help automating 'read in process' and general automating help

On Aug 25, 11:40*am, Spon <christoph.b...@gmail.com> wrote:
> On Aug 25, 4:46*am, mbwel...@gmail.com wrote:
>
>
>
>
>
> > Thanks for the response, I have another question though.

>
> > For the

>
> > IDL> help,table,/structure
> > ** Structure <1229360>, 3 tags, length=300, data length=300, refs=1:
> > * *FIELD1 * * * * *INT * * * Array[*]
> > * *FIELD2 * * * * *FLOAT * * Array[*]
> > * *FIELD3 * * * * *FLOAT * * Array[*]
> > IDL> a6=fltarr(3,*)

>
> > How might I set it up so that the * in the array automaticaly becomes
> > placed in the fltarr? i.e. if: array[30] then automatically place 30
> > into fltarr such that fltarr(3,30).
> > *The table structure is throwing me off.

>
> > Thanks,
> > Matt

>
> a6 = Transpose( [ [Table.Field1], [Table.Field2], [Table.Field3] ] )
>
> Search for the array concatenation tutorial onhttp://www.dfanning.com
>
> Regards,
> Chris- Hide quoted text -
>
> - Show quoted text -


I guess the actual answer to your question is that you should be able
to get array sizes out of the structure like this:
NCols = N_Elements(Table.Field1)

My solution just skips that bit and joins up the structure fields into
one array, automatically converting the int column to floats in the
process.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:18 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.