Skip to main content

Wrapper around the Azure Storage Blobs SDK to make life a bit easier

Project description

EasyAdls

Wrapper around the Azure Storage Blobs SDK to make life a bit easier.

Install

pip install EasyAdls

Examples

Get a client with either a key or sas token:

from EasyAdls import EasyBlob

client = EasyBlob(account_name='mystorageaccount',
                  container='some-container',
                  credential='key_or_sas_token')

Retrieve properties of a blob:

# return properties
client.get_properties('blob.jpg')

Copy a blob. You can specify another container if needed, default is same container:

# copy a blob
client.copy_blob('blob.jpg', 'copy_of_blob.jpg')

client.copy_blob(source_path='blob.jpg',
                 destination_path='copy_of_blob.jpg',
                 destination_container='anothercontainer')

Move-, or rename a blob. You can specify another container if needed, default is same container

client.move_or_rename_blob('blob.jpg', 'renamed_blob.jpg')

client.move_or_rename_blob(source_path='/path/to/blob.jpg',
                           destination_path='/another/path/to/blob.jpg',
                           destination_container='anothercontainer')

Read / write a csv directly into a pandas dataframe. You can pass-down all arguments of pandas.read_csv() and pandas.to_csv():

# read csv
df = client.read_csv_to_pandas('some.csv', header=None, sep=',')

# write csv
client.write_pandas_to_csv(df, 'another.csv', overwrite=False, index=True)

Get a string of bytestring back from a blob:

# returns string
client.read_blob_to_string('some.csv')

# returns bytes
client.read_blob_to_bytes('blob.jpg')

Write any content into a blob, can be both string or bytestring:

# directly write to file
client.write_content_to_blob('some.txt', 'some random test string', overwrite=True)

Read a text blob into a StringIO object, so you can read it in with e.g., Pandas as if it was on disk:

# get StringIO
csv_as_string = client.read_textfile_to_io('some.csv')

# turn it into a pandas df
pd.read_csv(csv_as_string)

Read a (binary) blob into a BytesIO object, so you can read it in with e.g., Pandas as if it was on disk

# get BytesIO
csv_as_bytes = client.read_binary_to_io('some.csv')

# turn it into a pandas df
pd.read_csv(csv_as_bytes)

Upload a local file to blob or vice versa

# upload a file
client.upload_blob('./some_local.jpg', 'blob.jpg', overwrite=True)

# download a file
client.download_blob('blob.jpg', './some_local.jpg')

License

None whatsoever

Author

D. Koops

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EasyAdls-0.1.3.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file EasyAdls-0.1.3.tar.gz.

File metadata

  • Download URL: EasyAdls-0.1.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for EasyAdls-0.1.3.tar.gz
Algorithm Hash digest
SHA256 55b951de32563604ad60259da841a89ba5087e17145b10b9822002ec952389d5
MD5 dce03116218291a684d5b9470e51a508
BLAKE2b-256 633a3066392efce64311fb141f0ff851616673f6ac0d77c55a035a855892734e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page