for remote_path in list_of_stfp_paths:
with pysftp.Connection(HOSTNAME, username=USERNAME, password=PASSWORD) as sftp:
sftp.get(remote_path, str(local_path))
#checks distinct count of a column for the csv downloaded, deletes it later
df = pd.read_csv(str(local_path))
print(df['taken_time'].value_counts())
os.remove(str(local_path))
The code I use is above. It's just run in a for loop with multiple remote paths. Sometimes, it gets completed. Sometimes, I get an error saying
Exception: Authentication failed.