Returns readable file objects for all of the data files in a given directory that match a given glob pattern.
Parameters: | datadir : str
package : str, optional
pattern : str, optional
encoding : str, optional
|
---|---|
Returns: | fileobjs : iterator of file objects
|
Examples
This will retrieve the contents of the data file for the astropy.wcs tests:
>>> from astropy.utils.data import get_pkg_data_filenames
>>> for fd in get_pkg_data_fileobjs('maps', 'astropy.wcs.tests',
... '*.hdr'):
... fcontents = fd.read()
...