Skip to content

Instantly share code, notes, and snippets.

@blackrez
Created July 18, 2021 09:43
Show Gist options
  • Save blackrez/54f36d240ebfdfb5b0ba9b7bdb7ae8cf to your computer and use it in GitHub Desktop.
Save blackrez/54f36d240ebfdfb5b0ba9b7bdb7ae8cf to your computer and use it in GitHub Desktop.
import csv
import urllib.request
import codecs
url = "https://s3.amazonaws.com/carto-1000x/data/yellow_tripdata_2016-01.csv"
stream = urllib.request.urlopen(url)
csvfile = csv.DictReader(codecs.iterdecode(stream, 'utf-8'))
count = 0
z = 0.0
for line in csvfile:
z = float(line['tip_amount']) + z
count = count + 1
print("final")
print(z)
print(count)
avg = z/count
print(avg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment