def add_data(self, packet: DataPacket):
"""
Import a DataFrame into the project
:param packet: DataPacket custom class containing file path, dataframe, data type and flight association
:return: Void
"""
self.log.debug("Ingesting data and exporting to hdf5 store")
file_uid = 'f' + uuid.uuid4().hex[1:] # Fixes NaturalNameWarning by ensuring first char is letter ('f').
with HDFStore(str(self.hdf_path)) as store:
# Separate data into groups by data type (GPS & Gravity Data)
# format: 'table' pytables format enables searching/appending, fixed is more performant.
store.put('{}/{}'.format(packet.data_type, file_uid), packet.data, format='fixed', data_columns=True)
# Store a reference to the original file path
self.data_map[file_uid] = packet.path
try:
flight = self.flights[packet.flight.uid]
if packet.data_type == 'gravity':
flight.gravity = file_uid
elif packet.data_type == 'gps':
flight.gps = file_uid
except KeyError:
return False
评论列表
文章目录