mmeval.fileio.list_from_file¶
- mmeval.fileio.list_from_file(filename, prefix='', offset=0, max_num=0, encoding='utf-8', backend_args=None)[source]¶
Load a text file and parse the content as a list of strings.
list_from_file
supports loading a text file which can be storaged in different backends and parsing the content as a list for strings.- Parameters
filename (str) – Filename.
prefix (str) – The prefix to be inserted to the beginning of each item.
offset (int) – The offset of lines.
max_num (int) – The maximum number of lines to be read, zeros and negatives mean no limitation.
encoding (str) – Encoding used to open the file. Defaults to utf-8.
backend_args (dict, optional) – Arguments to instantiate the preifx of uri corresponding backend. Defaults to None.
Examples
>>> list_from_file('/path/of/your/file') # disk ['hello', 'world'] >>> list_from_file('s3://path/of/your/file') # ceph or petrel ['hello', 'world']
- Returns
A list of strings.
- Return type
list[str]