You may wanna check on the numpy list as well.
I recently reimplemented a function to read text file as a combination of numpy.loadtxt and mlab.csv2rec, that handles missing data nicely. You can get it here for the moment:
The function you would need is mafromtxt, in fromascii. Alternatively, you can try using the scikits.timeseries package (http://pytseries.sourceforge.net/): recent SVN versions introduced tsfromtxt, that read a text file and return a timeseries.
However, none of these possibilities will work out-of-the-box, because of the presence of the footer. What you could do is write a first function that gets rid of this footer (example of MO: open the file, read all the lines in a list, get rid of the first 7 rows (header) and last 8 ones, store the result in a file). Once you have only the data, use mafromtxt (for example) using space as a delimiter, and specify the columns you want to use with usecols (that way, you can get rid of the column with the '*'). The missing data should be taken into account properly.
Let me know how it goes.
On Jan 17, 2009, at 2:16 AM, antonv wrote:
I know this is not related to matplotlib but this seems to be the only place
where I found people that have knowledge of both NOAA data and python so
please bear with me.
The .bull file that NOAA gives for upload is an ascii file formatted for
human readability but it creates a lot of issues when I am trying to parse
it. Here is a link to one of these files:
Do you have any idea on how to extract the data there in columns for
plotting with matplotlib? If you look at the file you'll notice that there
is both a header and a footer for the file that needs to be eliminated and
the main columns have sub columns also. Another issue is that in a column
there is missing data that should keep it's relationship with the time
column. And the last issue, some of the values there are preceded by a "*"
sign that should just be removed too.
Any ideas are greatly appreciated!
View this message in context: http://www.nabble.com/NOAA-.bull-file-parsing-tp21513800p21513800.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
This SF.net email is sponsored by:
SourceForge wants to tell your story.
Matplotlib-users mailing list