fp - the file object itself, you can iterate over them to get the lines in the file.
Example -
>>> f = open('test.csv','r') >>> f <_io.TextIOWrapper name='test.csv' mode='r' encoding='cp1252'>
You can only iterate over them; you cannot directly access a specific line in a file without using seek() or such a function.
fp.readlines() - this returns a list of all lines in the file, when you repeat this, you repeat the list of lines.
Example -
>>> f = open('test.csv','r') >>> lines = f.readlines() >>> lines ['order_number,sku,options\n', '500,GK-01,black\n', '499,GK-05,black\n', ',,silver\n', ',,orange\n', ',,black\n', ',,blue']
Here you can get the second line in the file using lines[1] , etc.
Usually, if the requirement is to simply iterate over the lines in the file, it is better to use file directly, since creating a list of lines and then repeating them will lead to unnecessary overhead.