Re: write_table

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 08 2012 - 11:12:01 MDT

Virginie,

Actually, with a little trick, you can make the header left alignment.
Like this example:

 a = (/111, 222, 333, 444/)
 b = (/1.1, 2.2, 3.3/)
 c = (/"a", "b", "c"/)
 d = (/11h, 22h/)
 f = (/11l, 22l, 33l, 44l, 55l, 66l/)

 alist = [/a, b, c, d, f/]

 header = (/"--------------------------------", \
            "This is a file header", \
            "--------------------------------"/)
 footer = (/"--------------------------------", \
            "This is a file footer", \
            "--------------------------------"/)

 hlist = [/header/]
 flist = [/footer/]

 str_write("list.txt", "w", hlist, "%s ")
 str_write("list.txt", "a", alist, "%d%16.2f%s%d%ld")
 str_write("list.txt", "a", flist, "%s ")
Which will produce:
--------------------------------
This is a file header
--------------------------------
111, 1.10,a,11,11
222, 2.20,b,22,22
333, 3.30,c, ,33
444, , , ,44
   , , , ,55
   , , , ,66
--------------------------------
This is a file footer
--------------------------------

The trick is to put an extra space in the header format between 's' and '"'.

Sorry for the confusion.

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Oct 8, 2012, at 8:05 AM, Wei Huang wrote:

> Virginie,
>
> Right now, NCL can only make the header right alignment.
>
> Wei
>
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
>
> On Oct 8, 2012, at 6:50 AM, virginie hergault wrote:
>
>> Hi users,
>>
>> I use the function str_write and I would like to know how to line up
>> the header with left alignment.
>>
>> Thank you,
>> Virginie
>>
>> 2012/10/5, David Brown <dbrown@ucar.edu>:
>>> Hi Virginie,
>>> According to Wei's earlier message, in 6.1.0-beta this routine is called
>>> str_write. It is going to be changed to write_table for the 6.1.0 release.
>>> Try str_write.
>>> -dave
>>>
>>>
>>> On Oct 5, 2012, at 12:00 PM, virginie hergault wrote:
>>>
>>>> Hello,
>>>>
>>>> I would like to use the function "write_table", that's why I installed
>>>> the version 6.1.0-beta of NCL.
>>>> But when I try to use it, I have the error:
>>>>
>>>> fatal:syntax error: possibly an undefined procedure
>>>>
>>>> Is it possible to use this function with the version 6.1.0-beta of NCL?
>>>>
>>>> Thank you for your answer,
>>>>
>>>> Virginie
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 8 11:12:14 2012

This archive was generated by hypermail 2.1.8 : Mon Oct 08 2012 - 15:54:16 MDT