with open("movies.txt") as infile:
    for line in infile:
        list1 = [ ]
        for temp in line.split(':'):
            list1.append(temp)
        if (list1[0] == 'product/productId'):
            if(list1[1] != product):
                product = list1[1]
                f1=open(list1[1],'w')
        elif(list1[0] == 'review/text'):
            if (list1[1] != product):
                f1.write(list1[1] + os.linesep)
i keep getting the ioerror which will disappear as soon as i use "for line in filename" instead of "with open(filename) as file:" help please
i have already tried all the solutin on this page Read large text files in Python, line by line without loading it in to memory but to no use
when i use this code it works perfectly fine...
for line in file_contents('movies.txt').splitlines():
    list1 = [ ]
    for temp in line.split(":"):
        list1.append(temp)
    for temp2 in line.split(":"):
        list1.append(temp2)
    if (list1[1] != product):
        if (list1[0] == 'product/productId'):
            product = list1[1]
            f1 = open(list1[1],'w')
        elif(list1[0] == 'review/text'):
            f1.write(list1[1] + os.linesep)
but i have to use the first code that i posted..
 
     
     
     
    