Guest User

Untitled

a guest
Jun 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def main():
  2.     #declare sum variable
  3.     sum = 0
  4.     #create file object that opens the given argument in read mode
  5.     fob = open(sys.argv[1], 'r')
  6.     #insert the large text file into variable data as a string
  7.     data = fob.readlines()
  8.    
  9.     newdata = []
  10.     for s in data:
  11.         s = s.strip().split(',')
  12.         for t in s:
  13.             newdata.append(t.strip())
  14.        
  15.     removedata = newdata
  16.     removedata = list(set(removedata))
  17.    
  18.     d = {}
  19.    
  20.     for s in removedata:
  21.         d[s] = newdata.count(s)
  22.    
  23.     print(newdata)
  24.     print(d)
Add Comment
Please, Sign In to add comment