Skip to main content

AzFS is to provide convenient Python read/write functions for Azure Storage Account.

Project description

azfs

CircleCI codecov

AzFS is to provide convenient Python read/write functions for Azure Storage Account.

azfs can

  • list files in blob,
  • check if file exists,
  • read csv as pd.DataFrame, and json as dict from blob,
  • write pd.DataFrame as csv, and dict as json to blob,
  • and raise lots of exceptions ! (Thank you for your cooperation)

install

$ pip install azfs

usage

create the client

import azfs
from azure.identity import DefaultAzureCredential

# credential is not required if your environment is on ADD
azc = azfs.AzFileClient()

# credential is required if your environment is not on ADD
credential = "[your storage account credential]"
# or
credential = DefaultAzureCredential()
azc = azfs.AzFileClient(credential=credential)

types of authorization

Currently, only support Azure Active Directory (ADD) token credential.

download data

azfs can get csv or json data from blob storage.

import azfs
import pandas as pd

azc = azfs.AzFileClient()

# read csv as pd.DataFrame
df = azc.read_csv("https://[storage-account].../*.csv")
# or
with azc:
    df = pd.read_csv_az("https://[storage-account].../*.csv")

data = azc.read_json("https://[storage-account].../*.json")

upload data

import azfs
import pandas as pd

azc = azfs.AzFileClient()

df = pd.DataFrame()
data = {"example": "data"}

# write csv
azc.write_csv(path="https://[storage-account].../*.csv", df=df)
# or
with azc:
    df.to_csv_az(path="https://[storage-account].../*.csv", index=False)

# read json as dict
azc.write_json(path="https://[storage-account].../*.json", data=data)

enumerating or checking if file exists

import azfs

azc = azfs.AzFileClient()

# get file list of blob
file_list = azc.ls("https://[storage-account].../")

# check if file exists
is_exists = azc.exists("https://[storage-account].../*.csv")

remove, copy files

import azfs

azc = azfs.AzFileClient()

# copy file from `src_path` to `dst_path`
src_path = "https://[storage-account].../from/*.csv"
dst_path = "https://[storage-account].../to/*.csv"
is_copied = azc.cp(src_path=src_path, dst_path=dst_path, overwrite=True)

# remove the file
is_removed = azc.rm(path=src_path)

dependencies

pandas >= "1.0.0"
azure-identity >= "1.3.1"
azure-storage-file-datalake >= "12.0.0"
azure-storage-blob >= "12.3.0"

references

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

azfs-0.1.3.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azfs-0.1.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: azfs-0.1.3.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for azfs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7aa7c3f59a80ef7d72ff1e950eabd9d6fc42b50046866d347edfc75e2a7af319
MD5 77052d2a48af2e3dcb34a356f239e987
BLAKE2b-256 2346de58a1b0bd810db917aa466a753a502c8191aaaf35a92c9d83f2b1322e1e

See more details on using hashes here.

File details

Details for the file azfs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: azfs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for azfs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3e08b4530e4581dd2cea995151079a82ef706a0ca18afa12ba0cb5ac1b623fd
MD5 cfde38d741cffeb796f749236f1a29bc
BLAKE2b-256 5812276f31993351f7a9daee15bfa16ab45253a66f2519f232422b72301f8107

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