Re: formatted output file with string

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 25 2012 - 06:46:59 MDT

The example writes a 'formatted string'

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

;---Generate some dummy integer, float, and string data
    npts = 100
    i = ispan(1,npts,1)
    j = generate_unique_indices(npts)
    k = generate_unique_indices(npts)
    x = random_uniform(-10,10,npts)
    y = random_uniform(0,1000.,npts)
    str1 = "string_" + sprinti("%03i", j)
    str2 = "string_" + sprinti("%03i", k)

;---Create an array of strings with formatted fields
    lines = str1 + \
            sprintf("%8.2f",x) + \
            sprinti("%4.0i", i) + \
            sprintf("%8.1f",y) + \
            " " + str2

;---Write to a file
   asciiwrite("file.txt",lines) ; <----------- write to file

On 6/25/12 2:11 AM, ousmane ndiaye wrote:
> Dear all,
> I want to save in a file some text and data (float) in a formatted way.
> I only see this example
> http://www.ncl.ucar.edu/Applications/o-ascii.shtml but here I can't see
> way to write formatted string.
> Ousmane
>
>
>
> _______________________________________________
> 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 Jun 25 06:47:10 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT