python scripts to parse visum .net and .dmd file to pandas and store as .csv files (c) Rafal Kucharski, Politechnika Krakowska, Krakow, Poland
open ptv_visum_to_pandas.py
and go to main()
where you can find the below pipeline:
NETPATH = "./test/MOMM_net.net" # .net file to parse into csv tables
DMDPATH = "./test/MOMM_full_dmd.dmd" # .dmd file to parse into csv tables
OUTPATH = "./test/data/" # save the .csv's here
VERPATH = "./test/test_matrices.ver"
export_net_dmd(path=VERPATH)
parse(NETPATH, export_path=OUTPATH) # a) full export
parse(NETPATH, export_path=OUTPATH, export_list=["Links", "Nodes"]) # b) just some tables
parse(DMDPATH, export_path=OUTPATH)
matrices_export_via_com(VERPATH, export_path=OUTPATH) # a) full export
matrices_export_via_com(VERPATH, export_path=OUTPATH, export_list=[101, 102]) # b) just some matrices
test_read("./test/data/Tripgeneration.csv")
test_read("./test/data/Links.csv")
test_read("./test/data/Mtx_10.csv")
run test.py
to see if the links.csv
is as we expect and if matrix entries.csv
are the same. Use only for the original files.
pd.DataFrame(data, columns=cols).to_csv(OUTPATH+table_name+".csv")
can be easily modified to be used directly in pandas (e.g. dict of DataFrames, or h5 store).pipeline can be smoother if this is called from within Visum, you shall adddoneVisum.IO.SaveNet, Visum.IO.SaveDmd
to prepare the files under good paths and then use them inparse