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

Home » Public Forums » archive » Re: add a line and column into an array
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: add a line and column into an array [message #64021] Tue, 02 December 2008 11:12
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Dec 2, 11:09 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
>> Thank you all. I took the advice on data output part form Cris, and
>> Format from Jean, that worked.
>> Is there anyway to leave and empty row after several number of lines,
>> and input a semi colon or colon after each values?
>
>> thanks
>
> read the help page "Using Explicitly Formatted Input/Output"
> (accessible from the print help page)
>
> print, data, format = '(2(9(f,";")/))'
>
> (f,";") ==> put a semicolon after each value
> 9(f,";") ==> write 9 values
> (9(f,";")/) ==> write 9 values and finish with a new line
> 2(9(f,";")/) ==> write 2 times 9 values, then new line.
>
> To skip 2 lines, put // etc
>
> Jean

Thank you it helps a lot!
Re: add a line and column into an array [message #64025 is a reply to message #64021] Tue, 02 December 2008 09:09 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> Thank you all. I took the advice on data output part form Cris, and
> Format from Jean, that worked.
> Is there anyway to leave and empty row after several number of lines,
> and input a semi colon or colon after each values?
>
> thanks

read the help page "Using Explicitly Formatted Input/Output"
(accessible from the print help page)

print, data, format = '(2(9(f,";")/))'


(f,";") ==> put a semicolon after each value
9(f,";") ==> write 9 values
(9(f,";")/) ==> write 9 values and finish with a new line
2(9(f,";")/) ==> write 2 times 9 values, then new line.

To skip 2 lines, put // etc

Jean
Re: add a line and column into an array [message #64028 is a reply to message #64025] Tue, 02 December 2008 08:01 Go to previous message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Dec 2, 6:53 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
>>> for i = 0, 8, 1 do begin
>>>   printf, 1, name[i], data[i,*], format='(a, f)' ;- maybe you want data
>>> [*,i]
>>> endfor
>>> close, 1
>
>>> chris- Hide quoted text -
>
>>> - Show quoted text -
>
>> Thank you!
>> That should work. I thought it to complicated before. Does format='(a,
>> f)' handle to print all of the data in one line?
>> Sorry, my data is in office, not at home, so I can not test yet.
>
>> Cheears
>
> Hi,
> If it doesn't, try (a,9f)
>
> Personally, especially for small prints, I like to prepare my text
> before printing...
>
> textToPrint =[ transpose(name), [string(data)]]
> print, textToPrint
>
> You might want to add the format to the string() function
> Jean- Hide quoted text -
>
> - Show quoted text -

Thank you all. I took the advice on data output part form Cris, and
Format from Jean, that worked.
Is there anyway to leave and empty row after several number of lines,
and input a semi colon or colon after each values?

thanks
Re: add a line and column into an array [message #64035 is a reply to message #64028] Tue, 02 December 2008 04:53 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
>> for i = 0, 8, 1 do begin
>> printf, 1, name[i], data[i,*], format='(a, f)' ;- maybe you want data
>> [*,i]
>> endfor
>> close, 1
>>
>> chris- Hide quoted text -
>>
>> - Show quoted text -
>
> Thank you!
> That should work. I thought it to complicated before. Does format='(a,
> f)' handle to print all of the data in one line?
> Sorry, my data is in office, not at home, so I can not test yet.
>
> Cheears

Hi,
If it doesn't, try (a,9f)

Personally, especially for small prints, I like to prepare my text
before printing...

textToPrint =[ transpose(name), [string(data)]]
print, textToPrint

You might want to add the format to the string() function
Jean
Re: add a line and column into an array [message #64038 is a reply to message #64035] Mon, 01 December 2008 19:39 Go to previous message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Dec 1, 8:56 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Dec 1, 3:50 pm, Elkunn <Wasit.Weat...@gmail.com> wrote:
>
>
>
>
>
>> Hello,
>> I have an array of floating numbers. Can I add one line as the first
>> line of the array, and one column as the first column,
>> The data I would like to add is strings. Basically, I want to print
>> them into a txt file
>> E.G.:
>> data= fltarr(9,9)
>> years = ['1950', '1960', '1970', '1980', '1990', '2000', '2010',
>> '2020', '2030']
>> Name= ['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7',
>> 'test8', 'test9']
>
>> I want to print years as a 1st line of the txt file, and Name as the
>> 1st column, then the data array.
>
>> Thanks
>
> try something like this (untested)
>
> openw, 1, 'out.txt'
> printf, 1, years ;- you may need to transpose this to get it to print
> in one line
> for i = 0, 8, 1 do begin
>   printf, 1, name[i], data[i,*], format='(a, f)' ;- maybe you want data
> [*,i]
> endfor
> close, 1
>
> chris- Hide quoted text -
>
> - Show quoted text -

Thank you!
That should work. I thought it to complicated before. Does format='(a,
f)' handle to print all of the data in one line?
Sorry, my data is in office, not at home, so I can not test yet.

Cheears
Re: add a line and column into an array [message #64039 is a reply to message #64038] Mon, 01 December 2008 18:56 Go to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
On Dec 1, 3:50 pm, Elkunn <Wasit.Weat...@gmail.com> wrote:
> Hello,
> I have an array of floating numbers. Can I add one line as the first
> line of the array, and one column as the first column,
> The data I would like to add is strings. Basically, I want to print
> them into a txt file
> E.G.:
> data= fltarr(9,9)
> years = ['1950', '1960', '1970', '1980', '1990', '2000', '2010',
> '2020', '2030']
> Name= ['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7',
> 'test8', 'test9']
>
> I want to print years as a 1st line of the txt file, and Name as the
> 1st column, then the data array.
>
> Thanks

try something like this (untested)

openw, 1, 'out.txt'
printf, 1, years ;- you may need to transpose this to get it to print
in one line
for i = 0, 8, 1 do begin
printf, 1, name[i], data[i,*], format='(a, f)' ;- maybe you want data
[*,i]
endfor
close, 1

chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL app development with "Collections Framework"
Next Topic: help with "interpolate"

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

Current Time: Wed Oct 08 18:07:57 PDT 2025

Total time taken to generate the page: 0.00734 seconds