0 votes
34 views
How can I export the full contribution tree data?
in openLCA by (350 points)

1 Answer

0 votes
by (350 points)
 
Best answer

As far as I have been able to find, there is not yet an automated way to export the full contribution tree data. Some have proposed copying the contribution tree and pasting it into Excel. However, since there is no "expand all" option, copying all data is near impossible for big product systems. 

For anyone struggling with the same problem, I've written an AutoHotkey script that automatically expands all contribution tree entries above a certain user-defined threshold.

To use it:

  1. Download AutoHotkey
  2. Create a new script (right-click in file explorer > new > AutoHotkey script)
  3. Open the script with a text editor
  4. Paste the code from down this reply > save
  5. Double click to run the script > follow the onscreen instructions
  6. Once finished press Esc (to quit script) > Ctrl A, Ctrl C (to copy all relevant entries)

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

MsgBox, Script has started: `n`n1. Fully collapse the contribution tree `n2. Select the first row `n3. Press space bar `n(press Esc to end script)

space::
InputBox, tresh, Treshold Specification, Input the treshold percentage `n`ne.g. 16.99 (max 2 places after decimal point)

Loop
{
 clipboard := ""  ; Start off empty to allow ClipWait to detect when the text has arrived.
 Send ^c ; Copy information of current selected entry 
 ClipWait  ; Wait for the clipboard to contain text.

 StartingPos := InStr(clipboard, "%") - 6
 cont := SubStr(clipboard, StartingPos, 6) ; Retrieve contribution percentage
 cont := LTrim(cont) ; Clean cont

 if cont >= %tresh% ; Check of currently selected entry is above treshold
 {
  Send, {right} ; Expand entry
 }
 Send, {down} ; Next entry
 Sleep, 5 ; Wait 5 milliseconds
}

Return

Esc::ExitApp ; Quit script
...