Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import csv
  2.  
  3. slurCount = 0
  4. noSlurCount = 0
  5.  
  6. with open('target_file.csv', encoding="utf8") as csv_file:
  7. csv_reader = csv.reader(csv_file, delimiter=',')
  8. slurList = ["slurX", "slurY", "SlurZ", "slurETC"]
  9. line_count = 0
  10. for row in csv_reader:
  11. if line_count == 0:
  12. print(f'Column names are {", ".join(row)}')
  13. line_count += 1
  14. else:
  15. commentText = {row[2]}
  16. if commentText in {row[2]}:
  17. slurCount += 1
  18. print ("t Comment contained a slur")
  19. else:
  20. noSlurCount += 1
  21. print ("t Comment didn't contain a slur")
  22. print(f't The comment ID is: {row[0]}')
  23. print(f't Their comment was: {row[2]}')
  24. print(f't The comment received: {row[3]} likes.')
  25. line_count += 1
  26. print(f'Processed {line_count} lines.')
  27. print(f'Found {slurCount} comments with slurs.')
  28. print(f'Found {noSlurCount} comments without slurs.')`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement