Skip to content

Instantly share code, notes, and snippets.

@sdorsett
Last active April 13, 2019 13:50
Show Gist options
  • Save sdorsett/1f5afe12e423540a54c0bfc87c0c36dd to your computer and use it in GitHub Desktop.
Save sdorsett/1f5afe12e423540a54c0bfc87c0c36dd to your computer and use it in GitHub Desktop.
Bold Idea - python - csv import and parse data example
import csv
with open('~/Documents/github-projects/nflscrapR-data/games_data/regular_season/reg_games_2018.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
print(f'Column names are {", ".join(row)}')
line_count += 1
else:
print(f'\t{row[2]} vs {row[3]} was {row[-2]} to {row[-1]}.')
line_count += 1
print(f'Processed {line_count} lines.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment