researchutils
master

Contents:

  • API Reference
    • Utilities related to arrays
    • Utilities related to chainer
    • Utilities related to files
      • Files
    • Utilities related to images
    • Utilities related to math
researchutils
  • Docs »
  • API Reference »
  • Utilities related to files
  • Edit on GitHub

Utilities related to files¶

Files¶

researchutils.files.create_dir_if_not_exist(outdir)[source]¶

Check directory existence and creates new directory if not exist

Parameters:outdir (string) – Path of the file to create directory
Raises:RuntimeError – File exists in outdir but it is not a directory
researchutils.files.file_exists(path)[source]¶

Check file existence on given path

Parameters:path (string) – Path of the file to check existence
Returns:file_existence – True if file exists otherwise False
Return type:bool
researchutils.files.load_pickle(file_path)[source]¶

Load pickled data from file

Parameters:file_path (string) – Path of the file to load pickled data
Returns:data
Return type:data pickled in file
researchutils.files.prepare_output_dir(base_dir, args, time_format='%Y-%m-%d-%H%M%S')[source]¶

Prepare a directory with current datetime as name. Created directory contains the command and args when the script was called as text file.

Parameters:
  • base_dir (string) – Path of the directory to save data
  • args (dictionary) – Arguments when the python script was called
  • time_format (string) – Datetime format string for naming directory to save data
Returns:

out_dir

Return type:

directory to save data

researchutils.files.read_text_from_file(file_path)[source]¶

Read given file as text

Parameters:file_path (string) – Path of the file to read data
Returns:data – Text read from the file
Return type:string
researchutils.files.save_pickle(file_path, data)[source]¶

Pickle given data to file

Parameters:
  • file_path (string) – Path of the file to pickle data
  • data (data to pickle) –
researchutils.files.write_text_to_file(file_path, data)[source]¶

Write given text data to file

Parameters:
  • file_path (string) – Path of the file to write data
  • data (string) – Text to write to the file
Next Previous

© Copyright 2018, Yu Ishihara Revision 34a5e71f.

Built with Sphinx using a theme provided by Read the Docs.