Writing float array to file [message #91426] |
Tue, 14 July 2015 01:56  |
Kai Heckel
Messages: 51 Registered: April 2015
|
Member |
|
|
Hey there!
I have a quite simple problem but I didn't find a solution yet.
Given a float array with the dimensions 2048*5492 ("variables[0]"), I want to put these files in a .csv-file...
This is what I have:
b1=foldername[f]+'\b1.csv'
OPENW,1,b1
PRINTF,variables[0]
CLOSE,1
The error I get is:
PRINTF: Expression must be a scalar or 1 element array in this context: <FLOAT Array[2048, 5492]>.
What does it mean?
Thanks
|
|
|
Re: Writing float array to file [message #91427 is a reply to message #91426] |
Tue, 14 July 2015 02:25   |
Kai Heckel
Messages: 51 Registered: April 2015
|
Member |
|
|
Am Dienstag, 14. Juli 2015 10:56:16 UTC+2 schrieb Kai Heckel:
> Hey there!
>
> I have a quite simple problem but I didn't find a solution yet.
>
> Given a float array with the dimensions 2048*5492 ("variables[0]"), I want to put these files in a .csv-file...
>
> This is what I have:
>
> b1=foldername[f]+'\b1.csv'
> OPENW,1,b1
> PRINTF,variables[0]
> CLOSE,1
>
> The error I get is:
>
> PRINTF: Expression must be a scalar or 1 element array in this context: <FLOAT Array[2048, 5492]>.
>
> What does it mean?
>
> Thanks
Just found the mistake...
The line: "PRINTF,variables[0]"
Should be: "PRINTF,1,variables[0] "
|
|
|
Re: Writing float array to file [message #91428 is a reply to message #91426] |
Tue, 14 July 2015 03:22  |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
It means that you're missing the unit in the call of PRINTF
b1=foldername[f]+'\b1.csv'
OPENW, 1, b1
PRINTF, 1, variables[0]
CLOSE, 1
Anyway, it likely won't do what you want as variables[0] is just the first element of your matrix.
b1 = foldername[f]+'\b1.csv'
OPENW, un, b1, /get_lun
PRINTF, un, variables
FREE_LUN, un
In any case what you'll get is not really a csv (comma separated values) file. If that's what you want, then try to google how to write csv from IDL. If you plan to use the data for further analysis in IDL, csv is not very smart choice - one would rather go for plain ascii table, binary or the native IDL .sav format.
On Tuesday, July 14, 2015 at 9:56:16 AM UTC+1, Kai Heckel wrote:
> Hey there!
>
> I have a quite simple problem but I didn't find a solution yet.
>
> Given a float array with the dimensions 2048*5492 ("variables[0]"), I want to put these files in a .csv-file...
>
> This is what I have:
>
> b1=foldername[f]+'\b1.csv'
> OPENW,1,b1
> PRINTF,variables[0]
> CLOSE,1
>
> The error I get is:
>
> PRINTF: Expression must be a scalar or 1 element array in this context: <FLOAT Array[2048, 5492]>.
>
> What does it mean?
>
> Thanks
|
|
|