File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
activity_browser/app/bwutils Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 55
66from bw2data .utils import safe_filename
77from bw2io .export .excel import CSVFormatter , create_valid_worksheet_name
8+ from bw2io .export .csv import reformat
89import xlsxwriter
910
1011from .pedigree import PedigreeMatrix
1314# TODO: reminder to make a pull-request for these things in bw2io repo.
1415# - Add the 'nan_inf_to_errors' option when opening the xlsxwriter.Workbook.
1516# - Add handler for pedigree data to exporter
17+ # - Add 'database' field as required CSVFormatter export field.
18+ # - Add code to ensure no second 'activity' field is exported, as this
19+ # messes with following import.
1620
1721
1822class ABCSVFormatter (CSVFormatter ):
23+ def get_activity_metadata (self , act ):
24+ excluded = {"database" , "name" , "activity" }
25+ return {
26+ 'name' : act .get ("name" ),
27+ 'metadata' : sorted ([(k , reformat (v ))
28+ for k , v in act .items ()
29+ if k not in excluded
30+ and not isinstance (v , (dict , list ))
31+ ]),
32+ 'parameters' : self .get_activity_parameters (act )
33+ }
34+
1935 def exchange_as_dict (self , exc ):
2036 """Same as CSVFormatter, but explicitly pull the database from the
2137 input activity.
You can’t perform that action at this time.
0 commit comments