fname = "donna.SQL.txt"
txt = asciiread(fname, -1, "string")
print(txt)
nrow = dimsizes(txt)
ncol = str_fields_count(txt(0), ",") ; use initial line
print(ncol)
data = new( (/nrow,ncol/), "string")
do nr=0,nrow-1
data(nr,:) = str_split(txt(nr), ",")
end do
print(data) ; all elements are strings
lat = tofloat(data(:,1)) ; string to float
lon = tofloat(data(:,2))
z = tofloat(data(:,3))
===
As RickB comments ... not sure how you need 'time'
Good Luck
On 8/24/11 3:00 PM, Rick Brownrigg wrote:
> Hi Donna,
>
> Doesn't ascii read require data of all the same type? You might be able to convert your dates into "seconds since the epoch" via your sql query:
>
> http://www.postgresql.org/docs/8.1/static/functions-datetime.html
>
> (search for "epoch" on that page)
>
> I'm not sure how you'd reconstitute those values back into a timestamp in NCL; perhaps its not crucial to your app?
>
> Rick
>
> On Aug 24, 2011, at 12:53 PM, donna Cote wrote:
>
>> I'm familiar with asciiread but I'm stumped about how to go about taking
>> the output of a PostgreSQL query (text, rows of data) and loading those
>> columns into NCL arrays. How might I approach this idea?
>>
>> Sample query:
>> select datadatetime, longitude, latitude, depth, temperature, axbtidtext
>> from axbtdata order by axbtidtext, datadatetime limit 3;
>>
>> Sample output (comma-separated or can be space separated):
>> 2010-05-08 05:40:39-05,-85.051,28.341,0,23.07,2010-129-15:57:28
>> 2010-05-08 05:40:39-05,-85.051,28.341,-3,22.97,2010-129-15:57:28
>> 2010-05-08 05:40:39-05,-85.051,28.341,-1.5,23.07,2010-129-15:57:28
>>
>> Donna
>>
>> _______________________________________________
>> 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 Wed Aug 24 16:12:54 2011
This archive was generated by hypermail 2.1.8 : Thu Aug 25 2011 - 09:54:48 MDT