I have a python script that needs to read through a FASTA file character-by-character. To do this I have been using c = f.read(1)
, where f is the opened file. I need it to recognize when it reaches the end of a line, but '\n' and '\r' don't seem to work. I have never worked with this file type before so I'm not sure if FASTA is different. Does anyone know how to do this? Thanks!
Edit: EOF != EOL. I know how to find the end of file.
Edit 2: The line I'm using to search for the EOL character is this:
if c == '\n' or c == '\r':
#operations to perform if found...
Open the file in universal newline mode:
and compare the character against
'\n'
: