Store the directory name a file is in, and prepend this name to other files.
Examples
>>> indir = InDir('output/file1')
>>> print indir('file2')
Edit a file name by add a prefix, inserting a suffix in front of a file name extension or replacing the extension.
Parameters: | filename : str
prefix : str
suffix : str
new_ext : str, optional
|
---|---|
Returns: | new_filename : str
|
Check if path to filename exists and if not, create the necessary intermediate directories.
Returns the max. number of digits in range(n_step) and the corresponding format string.
Examples:
>>> get_print_info(11)
(2, '%2d')
>>> get_print_info(8)
(1, '%1d')
>>> get_print_info(100)
(2, '%2d')
>>> get_print_info(101)
(3, '%3d')
>>> get_print_info(101, fill='0')
(3, '%03d')
Locate all files matching fiven filename pattern in and below supplied root directory.
Read a NumPy array of shape (n_row, n_col) from the given file object and cast it to type dtype. If n_col is None, determine the number of columns automatically.
Read a single token (sequence of non-whitespace characters) from the given file object.
Notes
Consumes the first whitespace character after the token.
Remove all files and directories in supplied root directory.