@@ -0,0 +1,2277 @@
+package examples;%0A%0Aimport java.io.File;%0A%0Aimport org.openlca.core.database.IDatabase;%0Aimport org.openlca.core.database.ImpactMethodDao;%0Aimport org.openlca.core.database.ProductSystemDao;%0Aimport org.openlca.core.database.derby.DerbyDatabase;%0Aimport org.openlca.core.math.CalculationSetup;%0Aimport org.openlca.core.math.CalculationType;%0Aimport org.openlca.core.matrix.FastMatrixBuilder;%0Aimport org.openlca.core.matrix.MatrixData;%0Aimport org.openlca.core.matrix.io.CsvOut;%0Aimport org.openlca.core.model.AllocationMethod;%0Aimport org.openlca.core.model.ProductSystem;%0A%0A/*%0A * This example uses the %60FastMatrixBuilder%60 to export matrices with LCI and LCIA%0A * from a database.%0A */%0Apublic class FastMatrixExportExample %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09// set the path to the database folder here%0A%09%09String dbDir = %22C:/Users/ms/openLCA-data-1.4/databases/ecoinvent_2_2_unit%22;%0A%09%09try (IDatabase db = new DerbyDatabase(new File(dbDir))) %7B%0A%0A%09%09%09// The FastMatrixBuilder takes a normal calculation setup%0A%09%09%09// with a product system but it will build the LCI matrices%0A%09%09%09// for all processes in the database.%0A%09%09%09ProductSystem system = new ProductSystemDao(db).getForRefId(%0A%09%09%09%09%09%2253f9b9db-139f-4617-bf2b-8fc715b3cd16%22);%0A%09%09%09CalculationSetup setup = new CalculationSetup(%0A%09%09%09%09%09CalculationType.CONTRIBUTION_ANALYSIS, system);%0A%09%09%09setup.allocationMethod = AllocationMethod.USE_DEFAULT;%0A%09%09%09setup.impactMethod = new ImpactMethodDao(db).getDescriptorForRefId(%0A%09%09%09%09%09%22207ffac9-aaa8-401d-ac90-874defd3751a%22);%0A%0A%09%09%09// set withCosts to true, if you also want to export LCC matrices%0A%09%09%09// setup.withCosts = true;%0A%0A%09%09%09// define the folder where the matrices should be written%0A%09%09%09// the export will create the following files:%0A%09%09%09// A.csv: the product*product technology matrix%0A%09%09%09// B.csv: the flow*product intervention matrix%0A%09%09%09// C.csv: the indicator*flow matrix with characterization factors%0A%09%09%09// indexA.csv: the index of the matrix A%0A%09%09%09// indexB.csv: the index of the matrix B%0A%09%09%09// indexC.csv: the index of the matrix C%0A%09%09%09File outFolder = new File(%22target/matrices%22);%0A%09%09%09FastMatrixBuilder builder = new FastMatrixBuilder(db, setup);%0A%09%09%09MatrixData data = builder.build();%0A%09%09%09outFolder.mkdirs();%0A%09%09%09CsvOut.write(data, outFolder);%0A%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09%7D%0A%0A%7D%0A

add an example for the CSV based matrix export