Hi Philippe,
You can use sprinti and sprintf to format integers and floats into nice strings.
This allows you to create an array of strings that you can write to a file
using asciiwrite.
Here's an example using dummy data:
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)
Here's what the resulting file should look like:
string_031   -0.11   1   269.1    string_040
string_074    5.17   2   798.3    string_018
string_015    8.73   3   408.6    string_082
string_037    2.14   4   546.1    string_054
--Mary
On Feb 8, 2012, at 7:50 AM, PEYRILLE Philippe wrote:
> Hi all,
> 
> Does anyone of you know how to write an output ascii file with NCL that 
> contains mixed types of data (string and float).
>  For example I would like to write an output file with the first column 
> being a string and several other with numerical data.
> The function I use for writing out my data is write_matrix but it looks 
> like it does not handle string data.
> 
> Thanks,
> 
> Philippe
> 
> -
> 
> _______________________________________________
> 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 Wed Feb  8 08:20:08 2012
This archive was generated by hypermail 2.1.8 : Thu Feb 09 2012 - 13:33:26 MST