0

I am doing Problem Set 6 DNA. And it looks like the data given to me in the large file is incorrect. When I am running my code with small file it works fine. But when I run with large file it is not working.

Here is my code:

from csv import reader
from sys import argv

def main():
    if len(argv) < 3:
        print("Usage: python dna.py data.csv sequence.txt")
        exit()

    with open(argv[1], 'r') as file:
        readcsvdata = file.read()
    sequence_file = open(argv[2])

    line_list = list(sequence_file.readlines())
    i = 0
    count = []
    Recordcount = []
    readcsv = readcsvdata.split('\n')
    record = 0
    while i < (len(readcsv)-1):
        if(i == 0):
            Row_Record = readcsv[i].split(",")
            No_Of_Column = len(Row_Record)
            count = [0] * No_Of_Column
            j = 1
            while j < No_Of_Column:
                str1 = " "
                count[j] = len(str1.join(line_list).split(Row_Record[j].strip())) - 1
                j += 1
            j = 1
        else:
            Row_Record = readcsv[i].split(",")
            j = 1
            record = 1
            while(j < (No_Of_Column-1)):
                num1 = Row_Record[j]
                num2 = count[j]
                #if(Row_Record[j]!= count[j]):
                if(num1.strip() != str(num2).strip()):
                    record = 0
                    break
                j = j+ 1
            if(record == 1):
                print(Row_Record[0])
                break

        i = i + 1
    if(record == 0):
        print("No Match")
    sequence_file.close()

main()

According to me I guess that the large file has got a mistake or is wrong.

Please help me with this, as soon as possible.

1
  • To be brutally honest it is unlikely that "the large file has got a mistake or is wrong". (Assuming you are using an unchanged version of the supplied large.csv). Scores, maybe scores of scores, of students have gotten this pset correct with the supplied file. The supplied large.csv is 740 bytes, date 31-Oct-2019, cksum 4077149228. Sep 2 at 16:37

You must log in to answer this question.

Browse other questions tagged .