Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import time
- import re
- def find_lines():
- for x in range(len(randySeasonOne[speaker])):
- print(randySeasonOne[speaker][x])
- filename = ("/code/SouthParkData/Season-1.csv")
- speaker = input("Character Selection>>").strip()
- season = input("Season Selection>>").strip()
- episode = input("Episode selection>>").strip()
- print("-"*25)
- print("Here are all the lines from ", speaker)
- time.sleep(2)
- with open(filename, 'r') as file:
- reader = csv.DictReader(file, fieldnames=['season', 'episode', 'speaker', 'line'])
- lines = {speaker:[]}
- for row in reader:
- if row['speaker'] == speaker and row['season'] == season and row['episode'] == episode:
- print(row['speaker'])
- for x in range(len(lines[speaker])-1):
- line = re.sub(r'\A\W', ' ', row['line'])
- lines[speaker].append(line)
- print(lines[speaker][x])
- time.sleep(.125)
- ----------------------------------------------------------------------------Ouput
- Character Selection>>Kenny
- Season Selection>>1
- Episode selection>>9
- -------------------------
- Here are all the lines from Kenny
- Kenny
- Kenny
- Kenny
- Kenny
- Kenny
- Kenny
- Kenny
- --------------------------------------------------------Expected Ouput
- Kenny
- First line that has been sanitized with re.sub
- Kenny
- Second line, also sanitized
- Kenny
- Third line, sanitized
- etc..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement