Utils¶
Clean directory¶
-
scripts.utils.
clean_dir
(dirpath)[source] This function can be used to fully clear a directory.
- Arguments:
- dirpath (string) – path to directory to be cleared from files
Remove files from directory¶
-
scripts.utils.
remove_files
(dirpath, startname)[source] This function can be used to delete specific files from a directory. In general this function is used to clean country files from the ‘calc’ directory.
- Arguments:
dirpath (string) – path to directory in which the files should be removed
startname (string) – the substring to be searched for in the files
Create folder structure¶
-
scripts.utils.
create_folder_structure
(data_path, country)[source] Create the directory structure for the output.
- Arguments:
*base_path (string) – path to directory where folder structure should be created.
regionalized (bool) – specify whether also the folders for a regionalized analyse should be created (default: True)
Integer to date¶
-
scripts.utils.
int2date
(argdate: int)[source] If you have date as an integer, use this method to obtain a datetime.date object.
- Arguments:
- argdate (int) – Date as a regular integer value (example: 20160618)
- Returns:
- dateandtime.date – A date object which corresponds to the given value argdate.
Get integer from string¶
-
scripts.utils.
get_num
(x)[source] Grab all integers from string.
- Arguments:
- x (string) – string containing integers
- Returns:
- integer – created from string