Skip to main content

Python convenience function for opening compressed URLs and files.

Project description

Python convenience function canopener(filename, mode=’r’) for opening files.

Local files behave identically to open(). `python canopener('local_file.txt') `

URLs can also be passed as the filename and opened for reading. urllib2.urlopen() is used under the covers, so it has equivalent support. `python canopener('http://remote/file.txt') `

S3 URLs can also be read if the [boto](https://github.com/boto/boto) module is installed and the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set. The file is downloaded to a temporary local file on open. `python os.environ['AWS_ACCESS_KEY_ID'] = 'key' os.environ['AWS_SECRET_ACCESS_KEY'] = 'secret' canopener('s3://bucket/file.txt') `

Any paths with “.gz” or “.bz2” extensions are transparently decompressed. `python canopener('local_file.txt.gz') canopener('local_file.txt.bz2') canopener('http://remote/file.txt.gz') canopener('s3://bucket/file.txt.gz') `

There’s also transparent compression when writing to local files. `python canopener('local_file.txt.gz', 'w') `

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

canopener-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file canopener-0.1.0.tar.gz.

File metadata

  • Download URL: canopener-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for canopener-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ff0c9e53cceb53208edbdbcd7cd1e3e8dbf1ea04419ce5f5fa916d53dac91294
MD5 ad6fa311de13dfd84634ce8b2d82aaf8
BLAKE2b-256 85de8dd2853141f9bb48d5ddba60f48e4b7f79ba1e0ed3218fc4a8eee4929cc8

See more details on using hashes here.

Supported by

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