-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stages in different columns #1
Comments
If |
The issues seems to be that the csv output has its rows wrapped in quotation marks, rather than just row elements. The raw output looks like this:
while it should look like this:
or e.g. like this (delimiter
If you take a look at the source code, it seems the row elements are deliberately joined for csv export (cf. def _generate_spa_title_block(self, flow, to_csv=True or False):
"""
Creates a title block for the SPA results produced for each flows.
:param flow: flow being analysed
:param to_csv: boolean flag referencing whether the data is to be saved to csv file or not
:return: title block of the SPA results for a particular flow
"""
try:
flow_unit = self.flows_dict[flow].unit
except AttributeError:
raise AttributeError('The flow %s is not defined' % flow)
spa_title_block_list = [
['flow analysed:', flow],
['unit:',
"%s/%s" % (flow_unit, self.root_node.get_node_attribute(self.sector_definition_dict, 'Unit'))],
['thresholds:', str(self.thresholds_dict[flow])],
['direct:', str(self.root_node.direct_intensities[flow]), "%s/%s" %
(flow_unit, self.root_node.get_node_attribute(self.sector_definition_dict, 'Unit'))],
['total:', str(self.root_node.total_intensities[flow]), "%s/%s" %
(flow_unit, self.root_node.get_node_attribute(self.sector_definition_dict, 'Unit'))],
['% of total covered by SPA:', "{:.2%}".format(self.get_coverage_of(flow)),
'Note: Value may differ from sum of percentages in the table due to rounding']
]
if to_csv:
new_spa_title_block_list = []
for row in spa_title_block_list:
new_row = '\t'.join(row)
new_spa_title_block_list.append(new_row)
return new_spa_title_block_list
else:
return spa_title_block_list |
thanks for the package guys! I just applied it to ecoinvent. Here's what I did to create a column-wise df:
|
Hello and thank you for pySPA!
Is there a way to import the
export_to_csv()
results back into Python in a way that stages are given in different columns? I've usedpd.read_csv('file.csv')
and all results are given in a single column.The text was updated successfully, but these errors were encountered: