def save_sqlite(self): """ Save the circuit information in sqlite :return: logger with information """ logger = Logger() dfs = create_data_frames(self.circuit) save_data_frames_to_sqlite(dfs, file_path=self.file_name, text_func=self.text_func, progress_func=self.progress_func) return logger
def save_zip(self): """ Save the circuit information in zip format :return: logger with information """ logger = Logger() dfs = create_data_frames(self.circuit) save_data_frames_to_zip(dfs, filename_zip=self.file_name, text_func=self.text_func, progress_func=self.progress_func) return logger
def save_excel(circuit: MultiCircuit, file_path): """ Save the circuit information in excel format :param circuit: MultiCircuit instance :param file_path: path to the excel file :return: logger with information """ logger = Logger() dfs = create_data_frames(circuit=circuit) # flush-save ################################################################################################### writer = pd.ExcelWriter(file_path) for key in dfs.keys(): dfs[key].to_excel(writer, key) writer.save() return logger
def save_h5(circuit: MultiCircuit, file_path, compression_opts=5, text_func=None, prog_func=None): """ Save the circuit information in excel format :param circuit: MultiCircuit instance :param file_path: path to the excel file :param compression_opts: compression [0, 9] :param text_func: :param prog_func: :return: logger with information """ logger = Logger() dfs = create_data_frames(circuit=circuit) n = len(dfs) i = 0 for key, df in dfs.items(): if text_func: text_func('Saving ' + key + '...') df.to_hdf(file_path, key=key, complevel=compression_opts, complib='zlib') if prog_func: prog_func((i + 1) / n * 100) i += 1 return logger
text_func('select * from ' + key) dfs[key] = pd.read_sql('select * from ' + key, conn) # parse the configuration dfs = parse_config_df(dfs['config'], dfs) return dfs if __name__ == '__main__': import time from GridCal.Engine.IO.file_handler import * from GridCal.Engine.IO.pack_unpack import create_data_frames, data_frames_to_circuit # fname = '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/1354 Pegase.xlsx' fname = '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/IEEE39.gridcal' a = time.time() circuit_ = FileOpen(fname).open() print('native based open:', time.time() - a) print('Saving .sqlite ...') dfs = dfs = create_data_frames(circuit=circuit_) save_data_frames_to_sqlite(dfs, file_path=circuit_.name + '.sqlite') a = time.time() data = open_data_frames_from_sqlite(circuit_.name + '.sqlite') circuit2 = data_frames_to_circuit(data) print('sql based open:', time.time() - a)