Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- slurCount = 0
- noSlurCount = 0
- with open('target_file.csv', encoding="utf8") as csv_file:
- csv_reader = csv.reader(csv_file, delimiter=',')
- slurList = ["slurX", "slurY", "SlurZ", "slurETC"]
- line_count = 0
- for row in csv_reader:
- if line_count == 0:
- print(f'Column names are {", ".join(row)}')
- line_count += 1
- else:
- commentText = {row[2]}
- if commentText in {row[2]}:
- slurCount += 1
- print ("t Comment contained a slur")
- else:
- noSlurCount += 1
- print ("t Comment didn't contain a slur")
- print(f't The comment ID is: {row[0]}')
- print(f't Their comment was: {row[2]}')
- print(f't The comment received: {row[3]} likes.')
- line_count += 1
- print(f'Processed {line_count} lines.')
- print(f'Found {slurCount} comments with slurs.')
- print(f'Found {noSlurCount} comments without slurs.')`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement