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("mising command-line argument")
- exit(1)
- #pattern1 = re.compile(r'AGAT')
- #pattern2 = re.compile(r'AATG')
- #pattern3 = re.compile(r'TATC')
- # pattern = re.compile(r'contents[i:j]')
- with open(argv[1],"r") as file:
- count = 0
- contents = file.read()
- i = 0
- j = 4
- while contents[i:j]:
- span = contents[i:j]
- repcount = 1
- while contents[i+4:j+4] == span:
- repcount += 1
- i += 4
- j += 4
- #if repcount != 0:
- if repcount > 1:
- print("span " + span + " repeats " + str(repcount) + " times")
- i += 4
- j += 4
- else:
- i += 4
- j += 4
- #index = 0 ### these lines won't recognize header, because it's declared in the next open statement
- #for headervalue in header: # for each value in the header
- #index += 1 # keep track of which index in the line you are looking at
- #if headervalue == span: # if the value in the header matches the span that is looking to be matched
- #data = [row for row in contents] # look at each row of the
- #if int(data[index]) == repcount:
- #print("possible match is named " + data[0])
- with open(argv[2],"r") as csvfile:
- csvcontents = csv.reader(csvfile)
- header = next(csvcontents) # look up what next is doing again
- print("seeing what the next() function does by assigning it to header")
- print("printing header")
- print(header) ## assign header into a list
- data = [row for row in csvcontents]
- print("printing data[0]")
- # this line causes the program to crash, saying
- # valueError: invalid literal for int() with base 10: 'Neville'
- print(data[0]) # why don't lit let me print the name stored at data[0]?
- print("printing 1 line at a time")
- i = 0
- while i < len(data):
- print(data[i])
- i += 1
- print("print(data[15][2]) prints: ")
- print(int(data[15][2]))
- print("print(data[15][1]) prints: ")
- print(int(data[15][1]))
- print("print(data[15][0]) prints: ")
- print("header[1] prints: ")
- print(header[1])
- #print("printing everything in the csv file: ")
- #print(data)
Advertisement
Add Comment
Please, Sign In to add comment