I wrote a script in python 2.7 but want to switch to python 3.10 The only problem is that for some reason the readlines() command isn't producing the same results and is causing problems with my list comp. Below are the two different versions and their results:
Python 2.7
file_to_open = open('file.csv', 'r')
f = file_to_open.readlines()
print(len(f))
The result is 2001
Python 3.10
file_to_open = open('file.csv', 'r')
f = file_to_open.readlines()
print(len(f))
The result is 10401
The csv file does have 2001 rows so that is the correct number. There has to be some characters that are creating new lines or something that is screwing with the python 3 version. Has anyone encountered this before?