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 csvfile, open(argv[2],"r") as file: # arguments switched as suggested
- count = 0
- contents = file.read()
- csvcontents = csv.reader(csvfile)
- header = next(csvcontents)
- for item in header[1:]:# is there no reason to do this?
- #for item in header:
- beg = 0 # beginning index
- end = len(item) # item length
- seqrun = 0
- longest = 0
- #index = 0
- while beg + end <= len(contents):
- seqrun = 0
- while contents[beg: beg + end] == item:
- seqrun += 1
- beg += end
- if seqrun > longest:
- longest = seqrun
- beg += 1
- print(item + " repeats " + str(longest) + "times")
- # everything above here works... adding the code below causes the program to stop after the first string of longest repeats
- for value in header:# all these embedded loops are a bit bothersome
- index = 0
- while value != item: # how else might i keep track of item?
- index += 1 # figure out which index matches the item, such that you can compare the value found in large.csv to row[index]
- for row in csvcontents:
- if row[index] == item:
- print("possible match is named: ")
- print(row[0])
- #for value in csvcontents: # look at all the values in csv contents
- #if csvcontents[index] == item:
- #print("possible match is" + str(csvcontents[0]))
- #return csvcontents[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement