@@ -176,7 +176,23 @@ def generate_content_on_click(self, index):
176176 self .tabs .sankey .new_sankey ()
177177
178178 @QtCore .Slot (name = "lciaScenarioExport" )
179- def generate_lcia_scenario_export (self ):
179+ def generate_lcia_scenario_csv (self ):
180+ """Create a dataframe of the impact category results for all reference flows,
181+ impact categories and scenarios, then call the 'export to csv'
182+ """
183+ df = self .mlca .lca_scores_to_dataframe ()
184+ filepath , _ = QFileDialog .getSaveFileName (
185+ parent = self ,
186+ caption = "Choose location to save lca results" ,
187+ filter = "Comma Separated Values (*.csv);; All Files (*.*)" ,
188+ )
189+ if filepath :
190+ if not filepath .endswith (".csv" ):
191+ filepath += ".csv"
192+ df .to_csv (filepath )
193+
194+ @QtCore .Slot (name = "lciaScenarioExport" )
195+ def generate_lcia_scenario_excel (self ):
180196 """Create a dataframe of the impact category results for all reference flows,
181197 impact categories and scenarios, then call the 'export to excel'
182198 """
@@ -727,13 +743,23 @@ def build_export(
727743 # Then add the additional label and export btn, plus new stretch.
728744 exp_layout = QHBoxLayout ()
729745 exp_layout .addWidget (QLabel ("Export all data" ))
730- btn = QPushButton ("Excel" )
731- btn .setToolTip (
746+
747+ csv_btn = QPushButton (".csv" )
748+ csv_btn .setToolTip (
732749 "Include all reference flows, impact categories and scenarios"
733750 )
734751 if self .parent :
735- btn .clicked .connect (self .parent .generate_lcia_scenario_export )
736- exp_layout .addWidget (btn )
752+ csv_btn .clicked .connect (self .parent .generate_lcia_scenario_csv )
753+
754+ excel_btn = QPushButton ("Excel" )
755+ excel_btn .setToolTip (
756+ "Include all reference flows, impact categories and scenarios"
757+ )
758+ if self .parent :
759+ excel_btn .clicked .connect (self .parent .generate_lcia_scenario_excel )
760+
761+ exp_layout .addWidget (csv_btn )
762+ exp_layout .addWidget (excel_btn )
737763 layout .addWidget (vertical_line ())
738764 layout .addLayout (exp_layout )
739765 layout .addSpacerItem (stretch )
@@ -793,13 +819,23 @@ def build_export(
793819 # Then add the additional label and export btn, plus new stretch.
794820 exp_layout = QHBoxLayout ()
795821 exp_layout .addWidget (QLabel ("Export all data" ))
796- btn = QPushButton ("Excel" )
797- btn .setToolTip (
822+
823+ csv_btn = QPushButton (".csv" )
824+ csv_btn .setToolTip (
798825 "Include all reference flows, impact categories and scenarios"
799826 )
800827 if self .parent :
801- btn .clicked .connect (self .parent .generate_lcia_scenario_export )
802- exp_layout .addWidget (btn )
828+ csv_btn .clicked .connect (self .parent .generate_lcia_scenario_csv )
829+
830+ excel_btn = QPushButton ("Excel" )
831+ excel_btn .setToolTip (
832+ "Include all reference flows, impact categories and scenarios"
833+ )
834+ if self .parent :
835+ excel_btn .clicked .connect (self .parent .generate_lcia_scenario_excel )
836+
837+ exp_layout .addWidget (csv_btn )
838+ exp_layout .addWidget (excel_btn )
803839 layout .addWidget (vertical_line ())
804840 layout .addLayout (exp_layout )
805841 layout .addSpacerItem (stretch )
0 commit comments