Skip to content

Commit

Permalink
doc tweaks and further simplify csv usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zstumgoren committed Feb 23, 2013
1 parent c0a8d3c commit 15a627a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions projects/fdic/save_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ def convertdatestring(datestring):
except:
row[6] = ''

filename = os.path.join(PROJECT_DIR, 'fdic.txt')

# This is a Python idiom you'll see often.
# Below are a few Python idioms you'll see often.
# You're opening a file so that you can read data from it.
# Then, you use the csv module to help write the data to a file
# http://docs.python.org/2/library/csv.html#csv.DictReader
# Then, you use the csv module to help write data to the file.
# http://docs.python.org/2/library/functions.html#open
# http://docs.python.org/2/library/csv.html

filename = os.path.join(PROJECT_DIR, 'fdic.txt')
with open(filename, 'wb') as outputfile:
wtr = csv.writer(outputfile, delimiter='|', quotechar='"')
wtr = csv.writer(outputfile, delimiter='|')

# Add headers tooutput
wtr.writerow(headers)
Expand Down
2 changes: 1 addition & 1 deletion projects/fdic/save_to_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Commit our change
conn.commit()

# Get results data (recall that it's a list of two elements [headers, data]
# Get results data (recall that it's a list of two elements [headers, data])
results = scrape_data()
data = results[1]

Expand Down

0 comments on commit 15a627a

Please sign in to comment.