Re: writing out formatted text (string)

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 26 2012 - 06:07:50 MDT

You should send to ncl-talk@ucar.edu an attachment with a sample source
file and what you expect as output.

---
If you have 6.1.0-beta (latest release)
http://www.ncl.ucar.edu/Document/Functions/Built-in/str_write.shtml
---
  strs = asciiread("stn.txt", -1, "string")
;print(strs)
  newstrs = str_split_csv(strs, ",", 1)
;print(newstrs)
  nam = newstrs(:, 0)
  lat = tofloat(newstrs(:, 1))
  lon = tofloat(newstrs(:, 2))
  obs = tofloat(newstrs(:, 3))
  alist = [/nam, lat, lon, obs/]
  header = (/"--------------------------------", \
             "This is a file header", \
             "--------------------------------"/)
  footer = (/"--------------------------------", \
             "This is a file footer", \
             "--------------------------------"/)
  hlist = [/header/]
  flist = [/footer/]
  str_write("newstn.txt", "w", hlist, "%s ")
  str_write("newstn.txt", "a", alist, "%20s,%10.2f,%10.2f,%10.1f")
  str_write("newstn.txt", "a", flist, "%s ")
  str_write("newstn.txt", "a", alist, "%s%10.2f%10.2f%10.1f")
On 6/26/12 12:47 AM, ousmane ndiaye wrote:
> Dear all,
> I want to save in a file my data (text and numbers). Is there a way to
> write formatted string I saw this example but I'm looking for formatted
> character too, kind of "%s".
> I only saw 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 Tue Jun 26 06:07:57 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 29 2012 - 15:46:14 MDT