Last active
January 5, 2021 00:17
-
-
Save agalea91/7f8aa75fd8a2c03805192a9d643a0a48 to your computer and use it in GitHub Desktop.
Read CSV file on remote server over SSH, using local system RSA auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SSH_HOST = "" | |
SSH_USER = "" | |
SSH_FILE_PATH = "" | |
COMPRESSION = "zip" | |
from paramiko import SSHClient | |
client = SSHClient() | |
client.load_system_host_keys() | |
client.connect(SSH_HOST, username=SSH_USER) | |
sftp_client = client.open_sftp() | |
f = sftp_client.open(SSH_FILE_PATH) | |
df_chunks = pd.read_csv(f, chunksize=100000, compression=COMPRESSION) | |
for i, df in enumerate(df_chunks): | |
display(df.head()) | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment