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

Home » Public Forums » archive » Re: Extracting arrays into txt files
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: Extracting arrays into txt files [message #46063] Thu, 03 November 2005 06:28 Go to next message
txominhermos is currently offline  txominhermos
Messages: 25
Registered: October 2005
Junior Member
with the "width" statement it works nice



thanks for the help



Txomin
Re: Extracting arrays into txt files [message #46065 is a reply to message #46063] Thu, 03 November 2005 05:09 Go to previous messageGo to next message
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
Hi,

I guess you might want to use

openr, flun, filename, width=4000, /GET_LUN

The WIDTH keyword allows to surpress the carriage returns after 80
characters or so, whatever the default value is
Cheers,


Peter
Re: Extracting arrays into txt files [message #46068 is a reply to message #46065] Thu, 03 November 2005 04:18 Go to previous messageGo to next message
Peter Clinch is currently offline  Peter Clinch
Messages: 98
Registered: April 1996
Member
txominhermos@hotmail.com wrote:

> The main problem is that printing with printf, the samples are cut and
> continued in a diferent line.

By default, yes. I found out the default wrap is 10 fields, which
corresponded beautifully with my 10 x 10 test array. D'oh!

> So, is it possible to print the document
> with only one order or do I have to use loops and play with the format,
> inserting the tabs or commas?

You can explicitly define the format codes for the write. How you can
do that is shown in the Help, easiest to get there from the Printf help
and there's a link at Format (at least there is in 6.2...)

Something like

printf, 1, format='(50(" ", I, " ")), array

Will print 50 numbers to a line before wrapping. I don't think you need
to use loops.

Pete.
--
Peter Clinch Medical Physics IT Officer
Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital
Fax 44 1382 640177 Dundee DD1 9SY Scotland UK
net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
Re: Extracting arrays into txt files [message #46070 is a reply to message #46068] Thu, 03 November 2005 03:42 Go to previous messageGo to next message
txominhermos is currently offline  txominhermos
Messages: 25
Registered: October 2005
Junior Member
and thanks to peter as well!
Re: Extracting arrays into txt files [message #46071 is a reply to message #46070] Thu, 03 November 2005 03:40 Go to previous messageGo to next message
txominhermos is currently offline  txominhermos
Messages: 25
Registered: October 2005
Junior Member
Hi Norbert,


Thank u for the answer.

The main problem is that printing with printf, the samples are cut and
continued in a diferent line. So, is it possible to print the document
with only one order or do I have to use loops and play with the format,
inserting the tabs or commas?




Thanks again


Txomin
Re: Extracting arrays into txt files [message #46072 is a reply to message #46071] Thu, 03 November 2005 03:19 Go to previous messageGo to next message
Peter Clinch is currently offline  Peter Clinch
Messages: 98
Registered: April 1996
Member
txominhermos@hotmail.com wrote:

> I would like to know how to extract a full array into a txt file,
> maintaining the samples and collums format, to export it to a excel
> file or similar.

Programs like Excel can read ASCII text okay so as long as your array is
printed out with some sort of commonly used text separator (like white
space) there shouldn't be any problem.

You can do this very easily from IDL with PRINTF, so something like

array=indgen(10,10) ; here is an array you can use as a test
openw,1,'idl.txt' ; open a file for writing
printf,1,array ; write the array to the text file
close,1 ; close the file

If you open idl.txt in notepad or similar you'll see a plain text
representation of your array in rows and columns. If you use File |
Open in Excel it will ask you a couple of questions about the format but
it will have a correct guess so you can just go with the defaults, and
then your array will be in row and column format.

That's for 1 and 2d arrays. Obviously Excel won't be able to deal with
higher dimensional data quite as easily as IDL...

Pete.
--
Peter Clinch Medical Physics IT Officer
Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital
Fax 44 1382 640177 Dundee DD1 9SY Scotland UK
net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
Re: Extracting arrays into txt files [message #46073 is a reply to message #46072] Thu, 03 November 2005 03:10 Go to previous messageGo to next message
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
txominhermos@hotmail.com wrote:

> Hi!
>
>
>
> I would like to know how to extract a full array into a txt file,
> maintaining the samples and collums format, to export it to a excel
> file or similar.

The best format for exporting data is CSV. Numbers are in ASCII,
separated by either comma, semicolon or TAB, whatever you like.
The importing program should be told the separator you used
during export and maybe some more hints if the data isn't plain
integer or fixed point data. Hints are needed to date/time values,
currency values and such.

Text may be exported as well and each cell should be enclosed in
quotes.

To maintain the row/column of your arry you need to cycle thru
you data line by line. You may need to specify a format with the
print statement to avoid a new line after 80 or 256 bytes of
output as the receiving program will start a new line of input
if it detects a line feed in the data.

Norbert
Re: Extracting arrays into txt files [message #46074 is a reply to message #46073] Thu, 03 November 2005 03:02 Go to previous messageGo to next message
txominhermos is currently offline  txominhermos
Messages: 25
Registered: October 2005
Junior Member
Note: the arrays are quite bigs (3000 x 8000)
Re: Extracting arrays into txt files [message #46155 is a reply to message #46074] Mon, 07 November 2005 11:28 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
txominhermos@hotmail.com wrote:

> Note: the arrays are quite bigs (3000 x 8000)


Hmm, they must have worked on excel. Are you sure it can read 3000 columns?

What would be the colum name 3000 be?

I would guess it is
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZK


If one wants this good luck ;-)


cheers

Reimar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: reading wav files
Next Topic: Re: online help IDL 6.2

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

Current Time: Sun Nov 29 02:21:37 PST 2020

Total time taken to generate the page: 0.00642 seconds