Read, write, and transform iCSV files.
Project description
icsv
icsv is a Python package for reading, writing, validating, and transforming
interoperable CSV (iCSV) files.
Note: this repository provides the Python interface for iCSV. The iCSV format
specification itself is maintained in EnviDat/icsv:
https://gitlabext.wsl.ch/EnviDat/icsv
It supports:
- Standard iCSV files (
# iCSV 1.0 UTF-8) - 2D timeseries application profile files (
# iCSV 1.0 UTF-8 2DTIMESERIES) - Conversion of SMET-like objects into iCSV structures
Installation
pip install interoperable-csv
Import path stays:
import icsv
What Is iCSV?
iCSV is a text-based, self-describing data format for environmental time series. It combines CSV data rows with structured header metadata.
An iCSV file is organized in sections:
[METADATA]: global attributes (station info, geometry, delimiter, etc.)[FIELDS]: column definitions and per-column attributes[DATA]: tabular data rows
Typical header example:
# iCSV 1.0 UTF-8
# [METADATA]
# field_delimiter = ,
# geometry = POINTZ(9.81 46.831 2540.0)
# srid = EPSG:4326
# [FIELDS]
# fields = timestamp,hs
# [DATA]
Required metadata keys for standard files:
field_delimitergeometrysrid
Quickstart
import icsv
f = icsv.read("input.icsv")
print(f.get_field("fields"))
print(f.get_metadata("station_id"))
f.write("copy.icsv")
Create a new file:
import pandas as pd
import icsv
f = icsv.iCSVFile()
f.set_metadata("field_delimiter", ",")
f.set_metadata("geometry", "POINTZ(8.0 47.0 1200)")
f.set_metadata("srid", "EPSG:4326")
f.set_metadata("station_id", "WFJ")
f.set_fields("fields", ["timestamp", "hs"])
f.setData(pd.DataFrame({"timestamp": ["2024-01-01T00:00:00"], "hs": [40.2]}))
f.write("out.icsv")
2D timeseries profile support:
icsv.iCSV2DTimeseriesfor read/write of[DATE=...]blocksicsv.append_timepoint(...)to append profile timesteps
Core API:
icsv.read(path)auto-detects standard vs 2D profile formaticsv.iCSVFilestandard iCSV objecticsv.iCSV2DTimeseriesprofile objecticsv.from_smet(smet_obj)SMET to iCSV conversion
Documentation
Project documentation:
- GitLab Pages docs: https://git-pages.wsl.ch/patrick.leibersperger/icsv/
- Official iCSV format/spec website (GitLab Pages): https://gitlabext.wsl.ch/EnviDat/icsv/-/pages
- Format/spec repository: https://gitlabext.wsl.ch/EnviDat/icsv
For iCSV format specification changes, open issues at:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interoperable_csv-0.2.1.tar.gz.
File metadata
- Download URL: interoperable_csv-0.2.1.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55653c701d306a2959c61694436d456db6a0f54aaeafa1dc461b01c06dbe4ad7
|
|
| MD5 |
6fca145d7c20538220bb6b18ca02c4c4
|
|
| BLAKE2b-256 |
2bd31dbbe8d87232a4ad6727ea606357db3cbf061c8866b0ae748de43d170c3e
|
File details
Details for the file interoperable_csv-0.2.1-py3-none-any.whl.
File metadata
- Download URL: interoperable_csv-0.2.1-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b50f46c39a89f042f80e75d3a91c3f2fe408de0e90edffe4ed4d95be445eb88
|
|
| MD5 |
0cac1b565805c54e13d98cc0c6738b10
|
|
| BLAKE2b-256 |
1968cc21e8844cd7fbcbfce277927a79f5a53523bf9b750f2b956715493a7fdd
|