Closed answerquest closed 6 years ago
There's multiple approaches to tackle this:
KeyError
exceptions.Fixed by putting all db read commands in try-except blocks.
pd.HDFStore:
hdf = pd.HDFStore(dbFolder + tablename + '.h5')
try:
count = hdf.get_storer('df').nrows
except KeyError as e:
count = 0
logmessage('Note: {} does not have any data.'.format(tablename + '.h5'))
hdf.close()
pd.read_hdf:
try:
df = pd.read_hdf(dbFolder + h5File,'df').fillna('').astype(str)
except KeyError as e:
df = pd.DataFrame()
logmessage('Note: {} does not have any data.'.format(h5File))
Will update in code with v2.1.0
console output: