Guest User

Untitled

a guest
Jul 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. 92007
  2. 92011
  3. 92014
  4. 92024
  5. 1;
  6. 92058
  7. 92067
  8. 92075
  9. 92083
  10. 2;
  11.  
  12. nums = open('numbers.txt','r')
  13.  
  14. full = {}
  15. arr = []
  16.  
  17. while 1:
  18. read = nums.readline()
  19. if len(read) > 0:
  20. if len(read) == 6:
  21. read = read[0:5]
  22. arr.append(read)
  23. elif len(read) < 6:
  24. read = read[0]
  25. full[read] = arr
  26. arr = []
  27. else:
  28. break
  29.  
  30. csv = open('numbers.csv','w')
  31.  
  32. for i in full:
  33. for j in full[i]:
  34. line = str(j) + ',' + str(i) + 'n'
  35. csv.write(line)
  36.  
  37. csv.close()
  38.  
  39. read = read[0]
  40.  
  41. read = read[0:len(read)-2]
Add Comment
Please, Sign In to add comment