Advertisement
joseleeph

Untitled

Dec 13th, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. from sys import argv, exit
  2. import csv
  3. import re
  4. if len(argv) < 3:
  5. print("missing command line argument")
  6.  
  7. with open(argv[1],"r") as file, open(argv[2],"r") as csvfile:
  8. count = 0
  9. contents = file.read() #1. Read the sequence file into a string (you've got this).
  10. csvcontents = csv.reader(csvfile)
  11.  
  12. header = next(csvcontents)
  13. print("header prints")
  14.  
  15.  
  16. print("attempting to print rows of csvfile")
  17. for row in csvcontents:
  18. print(row)
  19.  
  20. #for item in contents:
  21. for item in header[1:]:
  22. #print("item prints:")
  23. #print(item)
  24. beg = 0 # beginning index
  25. end = len(item) # item length
  26. seqrun = 0
  27. longest = 0
  28. while contents[beg:beg+end]:
  29. #while beg + end <= len(contents):
  30. if contents[beg:beg+end] == item: # trying to solve the issue of end being incremented incorrectly here
  31. seqrun = 1
  32. #while contents[beg + len(item): beg + len(item)] == item:
  33. #while contents[beg: beg + len(item):end] == item:
  34. #while contents[beg:end] == item:
  35. #while contents[beg:beg+len(item): end + len(item)] == item:
  36. while contents[beg + end: end + end] == item:
  37. seqrun += 1
  38. #beg += len(item)
  39. beg += end
  40. #end += len(item) i don't need to increment end as well?
  41. if seqrun > longest:
  42. longest = seqrun
  43. beg += 1
  44. #end += 1
  45. print(item + " repeats " + str(seqrun) + "times")
  46. print("longest repeat is " + str(longest) + "times") # why is it longest?
  47.  
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement