@@ -0,0 +1,1578 @@
+from db import Scenario%0Afrom db import session%0Aimport pandas as pd%0A%0A%0Adef arraytofloat(x):%0A    if isinstance(x, list) and len(x) == 1:%0A        return x%5B0%5D%0A    else:%0A        return x%0A%0Apath = '/home/martin/renpass_gis/scenarios/'%0A%0A%0Ascenario_id = 1%0Ascenario = session.query(Scenario).filter(Scenario.id == scenario_id).all()%5B0%5D%0A%0A%0Ali = scenario.renpass_gis_storage_collection +%5C%0A    scenario.renpass_gis_source_collection +%5C%0A    scenario.renpass_gis_sink_collection%0A%0A%0Anodes_flows = %5B%5D%0Afor i in li:%0A    flow = vars(i)%0A    flow%5B'class'%5D = i.__table__.name%0A    nodes_flows.append(flow)%0A%0Anodes_flows = pd.DataFrame(nodes_flows)%0Anodes_flows = nodes_flows.applymap(arraytofloat)%0Anodes_flows%5B'class'%5D.replace(%7B'renpass_gis_storage': 'Storage',%0A                              'renpass_gis_linear_transformer':%0A                              'LinearTransformer',%0A                              'renpass_gis_sink': 'Sink',%0A                              'renpass_gis_source': 'Source'%7D, inplace=True)%0A%0Anodes_flows.drop('_sa_instance_state', 1, inplace=True)%0A%0Anodes_flows_seq = pd.DataFrame()%0A%0Adc = %7B%7D%0Afor idx, row in nodes_flows.iterrows():%0A    for k, v in row.items():%0A        if isinstance(v, list) and len(v) %3E 1:%0A            nodes_flows.loc%5Bidx, k%5D = 'seq'%0A            index = (row%5B'class'%5D, row%5B'label'%5D, row%5B'source'%5D, row%5B'target'%5D)%0A            dc%5Bindex%5D = v%0A%0Anodes_flows_seq = pd.DataFrame(dc)%0A%0Anodes_flows.set_index(%5B'class', 'label', 'source', 'target'%5D, inplace=True)%0Anodes_flows.to_csv(path + scenario.name + '_TEST.csv')%0Anodes_flows_seq.to_csv(path + scenario.name + '_seq_TEST.csv')%0A

Add csv creator