Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/greendelta/olca-simapro-csv
https://github.com/greendelta/olca-simapro-csv
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/greendelta/olca-simapro-csv
- Owner: GreenDelta
- License: mpl-2.0
- Created: 2021-10-09T08:04:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T13:07:04.000Z (4 months ago)
- Last Synced: 2024-09-17T16:22:52.484Z (4 months ago)
- Language: Java
- Size: 201 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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()));
}
```