-
-
Save plotti/150317c7a0998b1997ee1154b6beddc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Variante 1 | |
aarons = [] | |
with open("20151001_hundenamen.csv") as file: | |
for line in file: | |
data = line.split(",") | |
if data[0] == '"Aaron"': | |
if int(data[1]) > 2000 and int(data[1]) < 2012: | |
aarons.append(line) | |
len(aarons) | |
### Variante 2 | |
with open("20151001_hundenamen.csv") as file: | |
i = 0 | |
for line in file: | |
if i == 0: | |
print("Header") | |
else: | |
data = line.split(",") | |
if data[0].replace('"', '') == "Aaron": | |
print(data[0] + ":" + data[1]) | |
i = i+1 | |
### Variante 3 | |
dogs = {} | |
with open("20151001_hundenamen.csv") as file: | |
i = 0 | |
for line in file: | |
data = line.split(",") | |
if data[0] in dogs: | |
dogs[data[0]] += 1 | |
else: | |
dogs[data[0]] = 1 | |
dogs['"Aaron"'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment