This file contains hidden or 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
| #!/usr/bin/python | |
| # All SSH libraries for Python are junk (2011-10-13). | |
| # Too low-level (libssh2), too buggy (paramiko), too complicated | |
| # (both), too poor in features (no use of the agent, for instance) | |
| # Here is the right solution today: | |
| import subprocess | |
| import sys |
This file contains hidden or 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
| import airflow.hooks.S3_hook | |
| def upload_file_to_S3_with_hook(filename, key, bucket_name): | |
| hook = airflow.hooks.S3_hook.S3Hook('my_S3_conn') | |
| hook.load_file(filename, key, bucket_name) |
This file contains hidden or 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
| import datetime | |
| import logging | |
| from airflow import DAG | |
| from airflow.models import Variable | |
| from airflow.operators.python_operator import PythonOperator | |
| from airflow.hooks.S3_hook import S3Hook | |
| def list_keys(): |
This file contains hidden or 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
| def s3_to_pandas(client, bucket, key, header=None): | |
| # get key using boto3 client | |
| obj = client.get_object(Bucket=bucket, Key=key) | |
| gz = gzip.GzipFile(fileobj=obj['Body']) | |
| # load stream directly to DF | |
| return pd.read_csv(gz, header=header, dtype=str) | |
| def s3_to_pandas_with_processing(client, bucket, key, header=None): |