This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / lib / _datasource

module

numpy.lib._datasource

source: build-install/usr/lib/python3.14/site-packages/numpy/lib/_datasource.py :0

Members

Summary

A file interface for handling local and remote data files.

Extended Summary

The goal of datasource is to abstract some of the file system operations when dealing with data files so the researcher doesn't have to know all the low-level details. Through datasource, a researcher can obtain and use a file with one function call, regardless of location of the file.

DataSource is meant to augment standard python libraries, not replace them. It should work seamlessly with standard file IO operations and the os module.

DataSource files can originate locally or remotely:

  • local files'/home/guido/src/local/data.txt'

  • URLs (http, ftp, ...)'http://www.scipy.org/not/real/data.txt'

DataSource files can also be compressed or uncompressed. Currently only gzip, bz2 and xz are supported.

Example

>>> # Create a DataSource, use os.curdir (default) for local storage.
>>> from numpy import DataSource
>>> ds = DataSource()
>>>
>>> # Open a remote file.
>>> # DataSource downloads the file, stores it locally in:
>>> #     './www.google.com/index.html'
>>> # opens the file and returns a file object.
>>> fp = ds.open('http://www.google.com/') # doctest: +SKIP
>>>
>>> # Use the file as you normally would
>>> fp.read() # doctest: +SKIP
>>> fp.close() # doctest: +SKIP

Additional content

A file interface for handling local and remote data files.

The goal of datasource is to abstract some of the file system operations when dealing with data files so the researcher doesn't have to know all the low-level details. Through datasource, a researcher can obtain and use a file with one function call, regardless of location of the file.

DataSource is meant to augment standard python libraries, not replace them. It should work seamlessly with standard file IO operations and the os module.

DataSource files can originate locally or remotely:

  • local files'/home/guido/src/local/data.txt'

  • URLs (http, ftp, ...)'http://www.scipy.org/not/real/data.txt'

DataSource files can also be compressed or uncompressed. Currently only gzip, bz2 and xz are supported.

Example

>>> # Create a DataSource, use os.curdir (default) for local storage.
>>> from numpy import DataSource
>>> ds = DataSource()
>>>
>>> # Open a remote file.
>>> # DataSource downloads the file, stores it locally in:
>>> #     './www.google.com/index.html'
>>> # opens the file and returns a file object.
>>> fp = ds.open('http://www.google.com/') # doctest: +SKIP
>>>
>>> # Use the file as you normally would
>>> fp.read() # doctest: +SKIP
>>> fp.close() # doctest: +SKIP

Aliases

  • numpy.lib._datasource