Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/greendelta/olca-simapro-csv


https://github.com/greendelta/olca-simapro-csv

Last synced: 25 days ago
JSON representation

Awesome Lists containing this project

README

        

# olca-simapro-csv

`olca-simapro-csv` is an API for reading and writing the [SimaPro CSV format](./format.md).

## Usage

Include this dependency in your project:

```xml

org.openlca
olca-simapro-csv
3.0.5

```

You can directly read a CSV data set from a file:

```java
var dataSet = SimaProCsv.read(file);
```

Alternatively, you can read the content of a file block by block. This is useful
when you have large files that do not fit into memory:

```java
SimaProCsv.read(file, block -> {
if (block.isProcessBlock()) {
var process = block.asProcessBlock();
// ...
} else if (block.isUnitBlock()) {
var unitBlock = block.asUnitBlock();
// ...
}
});
```

A data set can be written to a file:

```java
dataset.write(file);
```

There is also a more low-level API to write data sets to a `CsvBuffer`:

```
CsvDataSet ds = ...
try (var writer = new FileWriter(file, SimaProCsv.defaultCharset())) {
ds.write(new CsvBuffer(writer, ds.header()));
}
```