Skip to content

Commit

Permalink
beginnings of another basic CSV parsing script
Browse files Browse the repository at this point in the history
  • Loading branch information
zstumgoren committed Feb 25, 2011
1 parent 4e8ab78 commit 71789cc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tutorials/textfiles101/read_data_from_CSV_2.py
@@ -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.