Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv, exit
- import csv
- import re
- if len(argv) < 3:
- print("missing command line argument")
- with open(argv[1],"r") as file, open(argv[2],"r") as csvfile:
- count = 0
- contents = file.read()
- csvcontents = csv.reader(csvfile)
- header = next(csvcontents)
- print("header prints")
- print(header)
- print("attempting to print rows of csvfile")
- for row in csvcontents:
- print(row)
- print("now header prints:")
- print(header)
- for item in header[1:]:
- #print("item prints:")
- #print(item)
- beg = 0 # beginning index
- end = len(item) # item length
- seqrun = 0
- longest = 0
- #while contents[beg:beg+len(item)]:
- while beg + end <= len(contents):
- #if contents[beg:beg+len(item)] == item: # trying to solve the issue of end being incremented incorrectly here
- seqrun = 0
- while contents[beg + len(item): beg + len(item)] == item:
- seqrun += 1
- beg += len(item)
- #end += len(item) i don't need to increment end as well?
- if seqrun > longest:
- longest = seqrun
- #beg += 1 why does beginning not need to be updated?
- end += 1
- print(item + " repeats " + str(seqrun) + "times")
- print(item + " the longest run is " + str(longest) + "items")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement