Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Hanlie Pretorius
Ok, now I see what I did. Legacy from when the get_rain_data function returned precipitation and error. I forgot to remove the brackets from the 'return [precip]' statement. It works perfectly now. Thanks for all the help. 2010/10/14, Evert Rol : >> Thanks for the reply. I've tried your suggestio

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Evert Rol
> Thanks for the reply. I've tried your suggestion and am still getting > an error (posted below code). Since my posting, I've also added the > code to convert the numpy array to a list. My complete script is: > > - > # -*- coding: utf-8 -*- > > import pupynere > import os > import csv > impo

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Hanlie Pretorius
Hi Evert, Thanks for the reply. I've tried your suggestion and am still getting an error (posted below code). Since my posting, I've also added the code to convert the numpy array to a list. My complete script is: - # -*- coding: utf-8 -*- import pupynere import os import csv import glob de

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Alan Gauld
"Hanlie Pretorius" wrote # file_details[0] is the date and file_details[1] is the time writer.writerow(('%s' % (file_details[0]),'%s' % (file_details[1]),'%f' % (data[0]))) Instead, I get an error TypeError: float argument required, not numpy.ndarray Try using %s instead of %f just to see w

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Evert Rol
> I have a numpy array ('data') that is the result of reading a netCDF > file, and it typically looks like this: > > array([ 0., 0., 0., 0.], dtype=float32) > > > I want to write this, after a date and time, to a CSV file, so the CSV > file would have the entry: > >2000-02-01,09:00,0.0,0

[Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Hanlie Pretorius
Hi, I have a numpy array ('data') that is the result of reading a netCDF file, and it typically looks like this: array([ 0., 0., 0., 0.], dtype=float32) I want to write this, after a date and time, to a CSV file, so the CSV file would have the entry: 2000-02-01,09:00,0.0,0.0,0.0,0.0 T