load_file_list

ndmapper.data.load_file_list(filename)[source] [edit on github]

Load a text file containing a list of filenames (or other strings) as a Python list.

To obtain a list of DataFile objects, the result can easily be converted as in the example:

>>> raw_biases = DataFileList(load_file_list('list_of_biases.txt'))

If the listed files need downloading first, the usage would be similar to:

>>> bias_list = load_file_list('list_of_biases.txt')
>>> download_files(bias_list, server='gemini', dirname='raw')
>>> raw_biases = DataFileList(bias_list, dirname='raw')

(or it may be preferable to produce the initial list by other means, such as command-line arguments or a list definition in the user script).

The DataFileList object can subsequently be used in place of the initial plain Python list.

Parameters:

filename : str

Name of a plain-text file, containing one entry per line. Although the intention is mainly to work with filenames, any non-comment strings are valid. Lines whose first non-whitespace character is ‘#’ are treated as comments.

Returns:

list of str

A list of filenames (or other strings), one per input line with any leading or trailing whitespace removed.