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

Home » Public Forums » archive » Re: Can IDL create a plain text file?
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: Can IDL create a plain text file? [message #51862] Thu, 14 December 2006 15:11
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:

> We all have new Mac Pros on our
> Christmas lists, but some of us are NOT optimistic. :-(

For pete's sake, man! Have you not been reading this newsgroup recently!?!?

:oD

paulv


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
Re: Can IDL create a plain text file? [message #51863 is a reply to message #51862] Thu, 14 December 2006 15:06 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matt writes:

> I'm learning quickly, considering, and am finishing preparations to
> process 4TB of satellite imagery.

Ah, in the past nothing would have identified you as
a newbie more than wanting to work with 4 TBytes of
data! But if you have been reading here in the past
couple of days, you will see that such data sets are
becoming de rigueur. We all have new Mac Pros on our
Christmas lists, but some of us are NOT optimistic. :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Can IDL create a plain text file? [message #51864 is a reply to message #51863] Thu, 14 December 2006 14:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matt writes:

> Question - can IDL create a plain text file of a filelist following
> user specifications? By this I mean that I'd like a text file listing
> files in a directory, but would like to enclose file names in quotes
> and add additional text to it. I imagine that this can be done by
> calling a PERL script but I'm wondering if IDL can do it internally.

Well, suppose you obtained your file list like this:

filelist = File_Search('*.pro')

Then, you could print the list out, with double quotes around
each file name, like this:

OpenW, lun, 'output.txt', /Get_Lun
FOR j=0,N_Elements(filelist)-1 DO BEGIN
PrintF, lun, '"' + filelist[j] + '"'
ENDFOR
Free_Lun, lun

Suppose you wanted to add the index number of the file
to each filename, you could do something like this:

OpenW, lun, 'output.txt', /Get_Lun
FOR j=0,N_Elements(filelist)-1 DO BEGIN
PrintF, lun, '"' + filelist[j] + '"' + ' ' + $
String(j, Format='(I2.2)')
ENDFOR
Free_Lun, lun

You could also format your string with a FORMAT statement
to the PRINTF command, similar to what I used with the
STRING command, above. There is almost infinite flexibility
in how this is done.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Can IDL create a plain text file? [message #51865 is a reply to message #51864] Thu, 14 December 2006 14:40 Go to previous message
Matt[1] is currently offline  Matt[1]
Messages: 23
Registered: December 2006
Junior Member
Thanks for the helpful responses and great leads. I'll give it a go.

Matt
www.landcover.org



On Dec 14, 5:24 pm, Christopher Thom <c...@oddjob.uchicago.edu> wrote:
> Hmmmm. Well, printing the stuff to the file is easy
>
> opewn, lun, 'myfile', /get_lun
> printf, lun, '"string in quotes"'
> free_lun, lun
>
> To append a parameter, say the contents of a variable myvar, you could
> use:
>
> str = '"string in quotes"'+strtrim(string(myvar),2)
> printf, lun, str
>
> the string() function converts myvar to a string, and strtrim() with the
> ",2" parameter trims the whitespace from the front and back. There are
> file_* routines that can help you construct the list of file -- see the
> help docs for those.
>
> cheers
> chris
>
> Quoth Matt:
>
>> I'm sorry david, it's not a trick question. I'm a geographer, not a
>> programmer, and one with about 2 months of IDL experience under my belt
>> to boot (and no other programming/scripting exposure at all). I think
>> I'm learning quickly, considering, and am finishing preparations to
>> process 4TB of satellite imagery. Nothing super high end, i'm sure, but
>> challenging nonetheless (at least to me).
>
>> A colleague mentioned that I should be able to create a text file in
>> IDL. Thie file will then be used as a paramater file for an ERDAS
>> Imagine script, which is called from IDL using SPAWN. Like I said
>> before, I've seen this done with PERL but given my deadlines I don't
>> have the time to go exploring PERL while still trying to learn IDL.
>
>> Silly question, I'm sure, but a real one nonetheless...
>
>> :-( indeed
>
>> Matt
>
>> On Dec 14, 4:13 pm, David Fanning <n...@dfanning.com> wrote:
>>> Matt writes:
>>>> Question - can IDL create a plain text file of a filelist following
>>>> user specifications? By this I mean that I'd like a text file listing
>>>> files in a directory, but would like to enclose file names in quotes
>>>> and add additional text to it. I imagine that this can be done by
>>>> calling a PERL script but I'm wondering if IDL can do it internally.This has GOT to be a trick question. I just can't
>>> see it though. :-(
>
>>> Cheers,
>
>>> David
>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Can IDL create a plain text file? [message #51866 is a reply to message #51865] Thu, 14 December 2006 14:24 Go to previous message
Christopher Thom is currently offline  Christopher Thom
Messages: 66
Registered: October 2006
Member
Hmmmm. Well, printing the stuff to the file is easy

opewn, lun, 'myfile', /get_lun
printf, lun, '"string in quotes"'
free_lun, lun

To append a parameter, say the contents of a variable myvar, you could
use:

str = '"string in quotes"'+strtrim(string(myvar),2)
printf, lun, str

the string() function converts myvar to a string, and strtrim() with the
",2" parameter trims the whitespace from the front and back. There are
file_* routines that can help you construct the list of file -- see the
help docs for those.

cheers
chris



Quoth Matt:

> I'm sorry david, it's not a trick question. I'm a geographer, not a
> programmer, and one with about 2 months of IDL experience under my belt
> to boot (and no other programming/scripting exposure at all). I think
> I'm learning quickly, considering, and am finishing preparations to
> process 4TB of satellite imagery. Nothing super high end, i'm sure, but
> challenging nonetheless (at least to me).
>
> A colleague mentioned that I should be able to create a text file in
> IDL. Thie file will then be used as a paramater file for an ERDAS
> Imagine script, which is called from IDL using SPAWN. Like I said
> before, I've seen this done with PERL but given my deadlines I don't
> have the time to go exploring PERL while still trying to learn IDL.
>
> Silly question, I'm sure, but a real one nonetheless...
>
> :-( indeed
>
> Matt
>
> On Dec 14, 4:13 pm, David Fanning <n...@dfanning.com> wrote:
>> Matt writes:
>>> Question - can IDL create a plain text file of a filelist following
>>> user specifications? By this I mean that I'd like a text file listing
>>> files in a directory, but would like to enclose file names in quotes
>>> and add additional text to it. I imagine that this can be done by
>>> calling a PERL script but I'm wondering if IDL can do it internally.This has GOT to be a trick question. I just can't
>> see it though. :-(
>>
>> Cheers,
>>
>> David
>>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>
Re: Can IDL create a plain text file? [message #51867 is a reply to message #51866] Thu, 14 December 2006 14:15 Go to previous message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
Check up file_search, openw, and printf - those should cover the job, I
would think.

regards,
Greg
Re: Can IDL create a plain text file? [message #51868 is a reply to message #51867] Thu, 14 December 2006 13:59 Go to previous message
Matt[1] is currently offline  Matt[1]
Messages: 23
Registered: December 2006
Junior Member
I'm sorry david, it's not a trick question. I'm a geographer, not a
programmer, and one with about 2 months of IDL experience under my belt
to boot (and no other programming/scripting exposure at all). I think
I'm learning quickly, considering, and am finishing preparations to
process 4TB of satellite imagery. Nothing super high end, i'm sure, but
challenging nonetheless (at least to me).

A colleague mentioned that I should be able to create a text file in
IDL. Thie file will then be used as a paramater file for an ERDAS
Imagine script, which is called from IDL using SPAWN. Like I said
before, I've seen this done with PERL but given my deadlines I don't
have the time to go exploring PERL while still trying to learn IDL.

Silly question, I'm sure, but a real one nonetheless...

:-( indeed

Matt

On Dec 14, 4:13 pm, David Fanning <n...@dfanning.com> wrote:
> Matt writes:
>> Question - can IDL create a plain text file of a filelist following
>> user specifications? By this I mean that I'd like a text file listing
>> files in a directory, but would like to enclose file names in quotes
>> and add additional text to it. I imagine that this can be done by
>> calling a PERL script but I'm wondering if IDL can do it internally.This has GOT to be a trick question. I just can't
> see it though. :-(
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Can IDL create a plain text file? [message #51870 is a reply to message #51868] Thu, 14 December 2006 13:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matt writes:

> Question - can IDL create a plain text file of a filelist following
> user specifications? By this I mean that I'd like a text file listing
> files in a directory, but would like to enclose file names in quotes
> and add additional text to it. I imagine that this can be done by
> calling a PERL script but I'm wondering if IDL can do it internally.

This has GOT to be a trick question. I just can't
see it though. :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Coincident values of string and numbers in 2 arrays..
Next Topic: Zipped Files

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

Current Time: Wed Oct 08 15:16:43 PDT 2025

Total time taken to generate the page: 0.00772 seconds