Browse files

beginnings of another basic CSV parsing script

  • Loading branch information...
1 parent 4e8ab78 commit 71789cc8c91cb0c30155367cdb3f06d918e81a07 @zstumgoren zstumgoren committed Feb 25, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 tutorials/textfiles101/
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+Below is a bare-bones example showing how to read data from a CSV.
+We combine a "for" loop with the "open" function to read each line
+and add it to a list.
+The "open" function accepts a number of extra options, but in
+in its most basic form can simply be called with the path to a file.
+# A list to store our data points
+data_store = []
+# Loop through lines, do some basic clean up, and
+# add data to our data_store
+for line in open('data/banklist.csv'):
+ clean_line = line.strip()
+ data_points = clean_line.split(',')
+ data_store.append(data_points)
+for line in data_store:
+ print line

0 comments on commit 71789cc

Please sign in to comment.