User:Statsrick/PHP modules

Python Modules I recommend and use

  1. import boto3 - aws sdk (the next generation after boto). Boto is a Python package that provides interfaces to Amazon Web Services. (sudo pip install boto)
  2. import botocore.exceptions - to capture aws sdk exceptions (example: except botocore.exceptions.ClientError)
  3. import urllib – interface to the internet/html
  4. import gzip – gzip interface (reading/writing)
  5. from datetime import datetime, timedelta - datetime manipulations (get today, yesterday)
  6. import sys – system module, I just use it to exit the script in case important files are missing
  7. import os – os interface – I use it to remove local files from disk
  8. import re – regex
  9. import urlparse – parse url into components
  10. import requests – web crawling
  11. import pgpasslib – password library for Redshift etc.
  12. import psycopg2 – postgres sql library for embedding Redshift statements

For analytics

  1. import pandas as pd (sudo pip install matplotlib pandas)
  2. import numpy as np
  3. import scipi as sp
  4. import mathsci as ms

install psycopg2 on a mac

#ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
#brew install postgresqlgem 
#install pgsudo -H pip 
#install psycopg2

using boto3 to read and write to s3 is easy and your creditials are stored here ~/.aws/credential

import boto3
s3_client = boto3.client('s3', region_name='us-west-2')
# Upload the file to S3 
s3_client.upload_file('hello-local.txt', 'MyBucket', 'hello-remote.txt') 
# Download the file from S3 
s3_client.download_file('MyBucket', 'hello-remote.txt', 'hello2-local.txt') 
print(open('hello2-local.txt').read())
#real example
s3_client.download_file('hearstlogfiles', 'adobe/omni-mgweb/2016/02/12/lookup_data.tar.gz', '/tmp/lookup_data.tar.gz')


Return to Rick's Library

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.