nrgpy.utils package#

Submodules#

nrgpy.utils.encodings module#

class nrgpy.utils.encodings.convert_utf16le_to_utf8(filename='', input_directory='', output_directory='', inplace=False)[source]#

Bases: object

for making Spidar data files compatible with programs that do not support utf-16-le character encoding

Parameters
filenamestr

(optional) path of file to convert

input_directorystr

(optional) path of directory with files to convert

output_directorystr

(optional) path of directory store converted files in

inplacebool

(False) if true, overwrites filename provided

Returns
None

Examples

convert single file

>>> import nrgpy
>>> filename = "/path/to/files/file.zip"
>>> nrgpy.convert_utf16le_to_utf8(filename)

convert directory of files

>>> input_directory = "/path/to/files/"
>>> nrgpy.convert_utf16le_to_utf8(input_directory=input_directory)
single_file()[source]#

nrgpy.utils.ipk2lgr module#

nrgpy.utils.ipk2lgr.callinterval(original)[source]#
nrgpy.utils.ipk2lgr.calltime(original)[source]#
nrgpy.utils.ipk2lgr.ipackinfo(typeint)[source]#
nrgpy.utils.ipk2lgr.ipackinfo_backup(phonestr)[source]#
nrgpy.utils.ipk2lgr.ipk2lgr(ipkfile)[source]#

nrgpy.utils.nsd_functions module#

nrgpy.utils.utilities module#

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

create directory if not exists

print status to terminal

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

determine which operating system python is running on

nrgpy.utils.utilities.count_files(directory, filters, extension, show_files=False, **kwargs)[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)[source]#
nrgpy.utils.utilities.data_months(start_date, end_date, output='string')[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, end_date, string)[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.draw_progress_bar(index, total, start_time, barLen=45, header='Time elapsed', label='')[source]#

simple text progress bar

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

Change out NRG Cloud site id with padded site number

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

checks pid list for instance of sympro running

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

assert folder_path ending with ‘/’

nrgpy.utils.utilities.load(site_number='', filename='')[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)[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='')[source]#

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

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

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

Module contents#