MPXJ: Export to Asta Powerproject - mpxj

I can successfully import Asta Powerproject project files. Then I do some stuff with it. And finally I have to export the data again to Asta Powerproject.
It seems like Asta Powerproject doesn't want to import neither MPX nor MSPDI files. Is there a way to export the data to a file that Asta Powerproject can import?

A quick test suggests that indeed Powerproject doesn't like valid MSPDI and PMXML files generated by MPXJ from a Powerproject PP file. i.e. these are files which will happily import into Microsoft Project and P6 respectively, but cause failures when an import into Powerproject is attempted.
You can see a minimal amount of failure logging in the Windows event log, but not enough to diagnose the issue. The PMXML import seems to get a bit further than the MSPDI import, and fails when the new PP file is being written. This appears to leave a log file in C:\Users\<user name>\AppData\Local\Temp which may shed some light on what it's having trouble with.
One way to address this might be to raise a support ticket with Elecosoft: they may be able to fix the issue on their end, or at least suggest what is causing the problem.
The other way to tackle this would be to export your PP file from Powerproject as an MSPDI or PMXML file and compare the structure with what MPXJ produces. You'd then need to start replacing the Powerproject generated content with MPXJ generated content element-by-element (or vice versa) until you trigger the failure when importing... which might lead you to the problematic data. Unfortunately it'll be a bit of a painstaking process.

Related

How can I use Brightway2 with US LCI database?

Short version:
I am trying to upload US LCI database to Brightway2 and I am failing miserably. Has anyone succeeded? If so, could you share it with me? :D
Long version:
I am following the notebook IO - Importing the US LCI database notebook and I am having a lot of problems. I am aware that, as the notebook indicates, it is a work in progress. Anyhow, I wanted to give it a try:
I tried uploading every ecospold version database found here, following the method from the notebook. The only one that gave me a similar results was version FY20.Q3.02. However, right off the bat I get the following differences/errors:
Same as the notebook, I get this error: Couldn't apply strategy link_technosphere_by_activity_hash: Object in source database can't be uniquely linked to target database. And two activities that are linked. When I follow the instructions of ignoring these datasets, it throws me that error over and over again.
Trying to move on with the tutorial, I get more errors and at the end I end up with all exchanges unlinked:
633 datasets
37513 exchanges
37505 unlinked exchanges
Finally, after running the code in line [15]:
import functools
f = functools.partial(link_iterable_by_fields,
other=Database(config.biosphere),
kind='biosphere'
)
sp.apply_strategy(f)
sp.statistics(f)
I end up with:
0 datasets
0 exchanges
0 unlinked exchanges
Which is hilarious and sad at the same time. Since I am new with Python and BW, my troubleshooting is clumpsy and probably erroneous (I promise I googled a lot and went through the code). And concluded I am failing and it is time to ask questions:
Has anybody succeeded uploading the US LCI database to Brightway2?
If so, how? Which file did you use?
Thank you!!!!
This is an excellent question. I have added text to the offending notebook to note that it is obsolete.
In general, I think trying to import the ecospold files is a fools errand, as though they are labeled ecospold2, they are actually ecospold1 (which is a totally different format):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ecoSpold xmlns="http://www.EcoInvent.org/EcoSpold01">
The most recent export also raises an error when I try the ecospold1 importer:
AttributeError: no such child: {http://www.EcoInvent.org/EcoSpold01}modellingAndValidation
This is a required attribute in ecospold1.
I think the best way forward would be to consume the JSON-LD directly. Note that it is important not to run bw2setup(), as you would also want to use their list of elementary flows and LCIA methods. Currently the experimental JSON-LD importer fails because the provided datasets need allocation, but don't provide a set of consistent allocation methods. When I use the git checkout of bw2io and do the following:
uslci = JSONLDImporter(
"/Users/cmutel/Downloads/National_Renewable_Energy_Laboratory-USLCI_Database/",
"US LCI",
preferred_allocation="CAUSAL_ALLOCATION"
)
uslci.apply_strategies()
I get the following error:
UnallocatableDataset: We currently only support exchange-specific CAUSAL_ALLOCATION
This is fixable, but someone would need to step through this and fix the allocation procedure, and I don't have the time to do that now.

The file is in the same directory but cannot be imported

The python version I am using is 3.8.2
I searched a lot and most of the solutions are to use sys.path.append()
But it didn't solve the problem for me, if I use from . import players
it will say
ImportError: attempted relative import with no known parent package
if i use import players it will say
ModuleNotFoundError: No module named 'players'
The code I used to fix this:
sys.path.append(".")
sys.path.append(os.getcwd() + "\\players.py")
sys.path.append(os.getcwd())
still can't fix this,It's worth mentioning that at some point sys.path.append(os.getcwd() + "\\players.py") can run
Make sure that the name of the file is actually players.py.
And not for example players.py, players .py (note the spaces).
Also check for all other "invisible" Unicode characters that would not necessarily show up.
And make sure that there is no directory players as well.
I deleted the file completely so I couldn't test it, but I ran into this problem again, it's an import order problem, I tried to import attributes.py first and then content.py, there was a problem Check, can't find attributes.py , the problem is solved when their import order is swapped, I can't understand why, but if you encounter such problems please try once (other files are not imported)
I've had similar issues and I've created a new, experimental import library for Python to solve this kind of import error: ultraimport
Instead of from . import players it allows you to write
import ultraimport
players = ultraimport('__dir__/players.py')
This will always work, no matter how you run your code, no matter what is your current working directory and no matter if there's another directory somewhere called 'players'.

export all package from one file, and then import them from this uniq source

I would like to export all my package from one single file, let's say exportAll.js and then across the code I may be able to import the one I need per file using something like
import { package1, package2 } from '../exportAll.js'
However I am concerning about the performance impact. I do believe after once import, Javascript save the reference for future import. However I also believe Javascript will first import all files into exportAll.js when I want to use only package1 and package2 and so, it may slow down the loading process of the first page who import anything from exportAll.
Can you help me to understand if this is bad for performance or even if this is bad practice for any other reason ?

import python file/module from parent/upper directory

i'm new to python and literely trying to import the module toolbox in the createRecipe.py file. Please see picture as it describes my problem
importProblem
I've looed in over 30 resources on the Internet and it seems there is no working solution for it. Though, i would like to raise the problem again, perhaps there is something new in python which makes this possible

Import Ecoinvent 2.2 Ecospold files into Brightway

I was trying to use the following code (Figure.1) to import Ecoinvent v2.2 into Brightway. I followed code from: https://github.com/PoutineAndRosti/Brightway-Seminar-2017/blob/master/Day%201%20AM/2%20-%20BW%20structure%20and%20first%20LCAs.ipynb
I obtained all XML (ecospold files) downloaded from Simapro (which is connected to ecoinvent database) and save all datafiles into the folder: C:\bw2-python\ecoSpold1.
However, when I run the next step, I ran into the following errors:
Figure 2
I am not sure what is wrong here. Any suggestion would be very helpful!
I think the ecospold files obtained from simapro and from the ecoinvent website are not the same. Simapro codes things a bit differently, which I think affects the naming of exchanges (that is why you got an invalid exchange). You either download the ecospold files from ecoinvent or use the tools see notebooks here and here to read exported csv files (the format prefered by simapro to export datasets).

Resources