Show parse_file.py syntax highlighted
# read in the cvs file family.dat
# open the file for reading
fh = file('../data/family.csv', 'r')
# slurp the header, splitting on the comma
headers = fh.readline().split(',')
# now loop over the remaining lines in the file and parse them
for line in fh:
# remove any leading or trailing white space
line = line.strip()
# split the line on the comma into separate variables
first, last, age, weight, height, dob = line.split(',')
# convert some of these strings to floats
age, weight, height = [float(val) for val in (age, weight, height)]
print first, last, age, weight, height, dob
results = []
for line in fh:
# process the line as above to get the variables
results.append( (first, last, age, weight, height, dob) )
See more files for this project here
Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends
Project homepage:
http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other
parse_file.py