nordlys.core.utils.file_utils module

File Utils

Utility methods for file handling.

Authors:Krisztian Balog, Faegheh Hasibi
class nordlys.core.utils.file_utils.FileUtils[source]

Bases: object

static dump_tsv(file_name, data, header=None, append=False)[source]

Dumps the data in tsv format.

  • file_name – name of file
  • data – list of list
  • header – list of headers
  • append – if True, appends the data to the existing file
static load_config(config)[source]

Loads config file/dictionary.

Parameters:config – json file or a dictionary
Returns:config dictionary
static open_file_by_type(file_name, mode='r')[source]

Opens file (gz/text) and returns the handler.

Parameters:file_name – NTriples file
Returns:handler to the file
static read_file_as_list(filename)[source]

Reads in non-empty lines from a textfile (which may be gzipped/bz2ed) and returns it as a list.