|
|
Re: Extracting arrays into txt files [message #46068 is a reply to message #46065] |
Thu, 03 November 2005 04:18   |
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 #46072 is a reply to message #46071] |
Thu, 03 November 2005 03:19   |
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 #46155 is a reply to message #46074] |
Mon, 07 November 2005 11:28  |
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
|
|
|