I am trying to use ftplib to count the number of lines in a file. This is what I have come up with so far.
ftp = FTP('ftp2.xxx.yyy')
ftp.login(user='xxx', passwd='yyy')
count = 0
def countLines(s):
nonlocal count
count += 1
x=str(s).split('\\r')
count += len(x)
ftp.retrbinary('RETR file_name'], countLines)
But the line count is off by a few ( I get about 20 more ), How can I fix it / Is there a better simpler solution