nrgpy.utils.utilities module#

nrgpy.utils.utilities.affirm_directory(directory: str) None[source]#

create directory if not exists

print status to terminal

nrgpy.utils.utilities.check_platform() linux[source]#

determine which operating system python is running on

nrgpy.utils.utilities.count_files(directory: str, filters: str, extension: str, show_files: bool = False, **kwargs) int[source]#

counts the number of files in the first level of a directory

Parameters:
directorystr

path of directory to be checked

filtersstr

filter present in file to be checked

extensionstr

secondary filter

show_filesbool, optional

if set to True, prints file name

start_timeint

seconds; if set, use as reference; only count if file is newer than start_time

nrgpy.utils.utilities.create_spd_filename_from_cloud_export(filename: str) str[source]#
nrgpy.utils.utilities.data_months(start_date: str, end_date: str, output: str = 'string') list[source]#

returns list of months for a date range in YYYY-mm-dd format

Parameters:
start_datestr or datetime

YYYY-mm-dd formatted date or datetime object

end_datestr or datetime

must be same formatting as start_date or god help you

outputstr

“string” or “datetime”; specify date types you want returned.

Returns:
list
nrgpy.utils.utilities.date_check(start_date: str, end_date: str, string: str) bool#

returns true if string date is between dates

Parameters:
start_datestr

“YYYY-mm-dd”

end_datestr

“YYYY-mm-dd”

stringstr

string including date to check

nrgpy.utils.utilities.draw_progress_bar(index, total, start_time, barLen=45, header='Time elapsed', label='') None[source]#

simple text progress bar

nrgpy.utils.utilities.fix_export_siteid_filename(filepath: str, site_number: str) str[source]#

Change out NRG Cloud site id with padded site number

nrgpy.utils.utilities.is_sympro_running() bool[source]#

checks pid list for instance of sympro running

nrgpy.utils.utilities.linux_folder_path(folder_path) str[source]#

assert folder_path ending with ‘/’

nrgpy.utils.utilities.load(site_number: str = '', serial_number: str = '', filename: str = '') object[source]#

recall a reader from a pickle file by site number or filename

Parameters:
site_numberstr

6-digit site number of stored reader OR spidar serial number

filenamestr

full or relative path of pickle file

Returns:
object

contents of pickle file

nrgpy.utils.utilities.rename_cloud_export_like_spd(filepath: str) bool[source]#

rename nrg cloud export files with SPD formatting

class nrgpy.utils.utilities.renamer[source]#

Bases: object

for replacing duplicate column names after transpose

nrgpy.utils.utilities.save(reader, filename='') None[source]#

save reader as a Python pickle file, to be recalled later

nrgpy.utils.utilities.set_start_stop(reader: object, with_time: bool = False) None[source]#
nrgpy.utils.utilities.string_date_check(start_date: str, end_date: str, string: str) bool[source]#

returns true if string date is between dates

Parameters:
start_datestr

“YYYY-mm-dd”

end_datestr

“YYYY-mm-dd”

stringstr

string including date to check

nrgpy.utils.utilities.windows_folder_path(folder_path) str[source]#

convert ‘/’ to ‘' in folder_path and assert ending in ‘'