Retrieves a data file from the standard locations for the package and provides a local filename for the data.
This function is similar to get_pkg_data_fileobj but returns the file name instead of a readable file-like object. This means that this function must always cache remote files locally, unlike get_pkg_data_fileobj.
Parameters : | data_name : str
|
---|---|
Returns : | filename : str
|
Raises : | urllib2.URLError :
IOError :
|
See also
Examples
This will retrieve the contents of the data file for the astropy.wcs tests:
from astropy.config import get_pkg_data_filename
fn = get_pkg_data_filename('data/3d_cd.hdr')
with open(fn) as f:
fcontents = f.read()
This retrieves a data file by hash either locally or from the astropy data server:
from astropy.config import get_pkg_data_filename
fn = get_pkg_data_filename('hash/da34a7b07ef153eede67387bf950bb32')
with open(fn) as f:
fcontents = f.read()