someone wrote: > .... > I want to put this table into an appropriate container > such that afterwards I want to: > > 1) Put the data into a mySql-table > 2) Be able to easily plot column 1 vs. either of the other columns > using matplotlib etc... > ....
Consider editing your data file into a csv file named someone.csv .... 20130315T071500,39000.,10,26,48000.,1,40 20130315T071501,39000.,10,26,48000.,2,42 20130315T071501,39000.,10,26,47520.,15,69 20130315T071501,39000.,10,26,47160.,1,70 20130315T071501,39000.,10,26,47000.,1,72 20130315T071501,39000.,10,26,47000.,2,81 20130315T071501,39000.,10,26,47000.,6,85 20130315T071501,39000.,10,26,46520.,10,95 20130315T071501,43000.,10,36,46520.,10,95 20130315T071501,43200.,4,43,46520.,10,104 20130315T071501,44040.,1,45,46520.,10,108 20130315T071501,44080.,3,48,46520.,10,109 20130315T071501,44080.,3,48,46520.,11,113 20130315T071501,44080.,3,48,46400.,2,131 20130315T071501,45080.,1,51,46400.,2,145 20130315T071501,45080.,1,51,46200.,1,147 20130315T071501,45080.,1,60,46120.,1,182 20130315T071501,45520.,1,65,46120.,1,225 20130315T071501,45520.,1,73,46120.,2,247 20130315T080000,45760.,1,133,46120.,2,378 20130315T080241,45760.,2,199,46120.,2,453 20130315T080945,45760.,3,217,46120.,2,456 20130315T081103,45760.,3,217,46080.,1,457 20130315T081105,45760.,3,218,46080.,2,458 20130315T081106,45760.,4,222,46080.,2,458 20130315T081107,45800.,1,229,46080.,2,458 20130315T082754,45800.,8,266,46080.,2,514 # ----------------------------------------------- # # The csv data can be loaded using the csv module # # named tuples might be used # for convenience to access # individual columns #!/usr/bin/env python import csv from collections import namedtuple as NT file_source = open( 'someone.ssv' ) # -------------------> individual column names --------------- nt = NT( 'csv_data' , 'date time col1 col2 col3 col4 col5 col6' ) list_tuples = [ ] for this_row in csv.reader( file_source ) : # unpack the current row zed , one , two , tre , fur , fiv , six = this_row # split the date and time d , t = zed.split( 'T' ) # convert individual columns in row to a named tuple this_tuple = nt( d , t , float( one ) , int( two ) , int( tre ) , float( fur ) , int( fiv ) , int( six ) ) # save the current named tuple into a list list_tuples.append( this_tuple ) # update_data_base( this_tuple ) # .... or .... # update_data_base( choose individual columns ) # individual elements of the named tuples # can be accessed by name # # this might be convenient for settup up # data for plots of diffeent columns print for row in list_tuples : print ' ' , row.date , row.time , row.col1 , row.col3 , row.col4 file_source.close() -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list