Skip to main content

pyimporters-csv

Sherpa knowledge import plugin for CSV, Excel and plain text files.

It registers three parsers through the pyimporters.plugins entry point group:

Plugin Class Extensions
text pyimporters_csv.text:TXTKnowledgeParser txt, text, zip
csv pyimporters_csv.csv_parser:CSVKnowledgeParser csv, tsv, zip
excel pyimporters_csv.excel:ExcelKnowledgeParser xls, xlsx

Each parser yields Term objects from pyimporters_plugins.base. Archives (zip) are unwrapped transparently for the text and CSV parsers.

Requirements

  • Python 3.12+
  • pyimporters_plugins (>=1.6.0,<1.7.0), pandas (>=2.0), structlog, openpyxl, xlrd

Installation

pip install pyimporters-csv

Usage

from pathlib import Path

from progress.bar import Bar

from pyimporters_csv.csv_parser import CSVKnowledgeParser, CSVOptionsModel

parser = CSVKnowledgeParser()
options = CSVOptionsModel(
    encoding="utf-8",
    identifier_col="ID",
    preferredForm_col="prefLabel_en",
    altForms_cols="altLabel_en",
    multivalue_separator="|",
)
terms = list(parser.parse(Path("terms.csv"), options.model_dump(), Bar("Processing")))

Options

TXTOptions (text parser):

Option Default Description
encoding utf-8 Encoding of the file

CSVOptions extends TXTOptions:

Option Default Description
separator , Field separator
quotechar " Quote character
multivalue_separator | Separator used to split multivalued columns
header 0 Row number (0-indexed) used as column names, blank if there is no header
identifier_col identifier Name of the column used as the concept identifier
preferredForm_col preferredForm Name of the column used as the preferred form
altForms_cols altForms Name of the column used as alternative forms

ExcelOptions is the same as CSVOptions without separator and quotechar.

The three *_col options take a column name, not an index: an unknown name falls back to the default (column 0 for the identifier, the identifier column for the preferred form, no alternative forms at all) and logs a warning. Values in altForms_cols are split on multivalue_separator, so a single column can hold several alternative forms.

Development

The build is driven by Task and uv, with the shared stages coming from the python-archetype submodule:

git submodule update --init
task stages          # print the pipeline stages, in order
task                 # run the pipeline up to (but excluding) py:publish
task -- --skip-tests # same, without the test stage
task up-to -- lint   # run the pipeline up to and including one stage
task jenkins         # run every stage, exactly what Jenkins runs

Individual stages:

Task Description
task py:sync Install the workspace and its dependencies (uv sync)
task py:lint ruff check and ruff format --check
task py:format Reformat the code with ruff
task py:test Run the test suite
task py:test-marker -- <m> Run the tests carrying one pytest marker
task py:sbom Generate a CycloneDX SBOM of the resolved environment
task py:check-vulnerabilities Check for known CVEs
task py:check-updates Check for dependency updates
task py:build Build the wheel and sdist (uv build)
task py:publish Publish the distributions (uv publish)

uv.lock is not versioned here (the Jenkinsfile removes it before building), so py:sync always resolves dependencies from scratch.

SBOM & vulnerability check

task py:sbom and task py:check-vulnerabilities wrap the underlying tools; to run them by hand:

uv sync --extra sbom
uv run cyclonedx-py environment -o sbom.cdx.json --output-format json
uv run pip-audit --format json --output audit-report.json
uv run pip-audit --strict   # fail on any known vulnerability

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyimporters_csv-1.6.31.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyimporters_csv-1.6.31-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pyimporters_csv-1.6.31.tar.gz.

File metadata

  • Download URL: pyimporters_csv-1.6.31.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyimporters_csv-1.6.31.tar.gz
Algorithm Hash digest
SHA256 eaedcc3392e20e49e2e3cfd3de5b0d36e16f336e766db32c80a7f1d2f1a42e9b
MD5 cd836d747519a35703c5a3503bdfb7a9
BLAKE2b-256 b63119048f09aa5b4433c2470cff82b705b39fa0620b288d7d999ef17523cd1d

See more details on using hashes here.

File details

Details for the file pyimporters_csv-1.6.31-py3-none-any.whl.

File metadata

  • Download URL: pyimporters_csv-1.6.31-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyimporters_csv-1.6.31-py3-none-any.whl
Algorithm Hash digest
SHA256 22113ebc8109bb5460b0bb59aa6a23e84079dee05afeb2c7eb01e72030b319b9
MD5 49af3925a612e6f7883b5d3895238460
BLAKE2b-256 766cf1d9121d3f371c64d567e990a3568a1cf72c09157798b16ca58c957c143f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.8.65

2 files

1.8.63

2 files

1.8.61

2 files

1.6.465

2 files

1.6.462

2 files

1.6.460

2 files

1.6.458

2 files

1.6.59

2 files

1.6.57

2 files

1.6.55

2 files

1.6.53

2 files

1.6.51

2 files

1.6.50

2 files

1.6.48

2 files

1.6.46

2 files

1.6.44

2 files

This release

1.6.31 This release

2 files

1.6.29

2 files

1.6.27

2 files

1.6.26

2 files

1.6.25

2 files

1.6.24

2 files

1.6.23

2 files

1.6.22

2 files

1.6.21

2 files

1.6.20

2 files

1.6.19

2 files

1.6.18

2 files

1.6.16

2 files

1.6.10

2 files

1.6.8

2 files

1.6.6

2 files

0.7.6

2 files

0.7.4

2 files

0.6.46

2 files

0.6.44

2 files

0.6.42

2 files

0.6.40

2 files

0.6.38

2 files

0.6.36

2 files

0.6.34

2 files

0.6.32

2 files

0.6.30

2 files

0.6.28

2 files

0.6.26

2 files

0.6.23

2 files

0.5.456

2 files

0.5.453

2 files

0.5.451

2 files

0.5.450

2 files

0.5.448

2 files

0.5.446

2 files

0.4.444

2 files

0.4.442

2 files

0.4.440

2 files

0.4.438

2 files

0.4.435

2 files

0.4.433

2 files

0.4.426

2 files

0.4.421

2 files

0.4.415

2 files

0.4.406

2 files

0.4.404

2 files

0.4.380

2 files

0.4.378

2 files

0.4.376

2 files

0.4.374

2 files

0.4.371

2 files

0.4.369

2 files

0.4.367

2 files

0.4.365

2 files

0.4.363

2 files

0.4.361

2 files

0.4.359

2 files

0.4.357

2 files

0.4.355

2 files

0.4.353

2 files

0.4.351

2 files

0.4.349

2 files

0.4.347

2 files

0.4.345

2 files

0.4.343

2 files

0.4.341

2 files

0.4.339

2 files

0.4.336

2 files

0.4.334

2 files

0.4.332

2 files

0.4.330

2 files

0.4.328

2 files

0.4.326

2 files

0.4.322

2 files

0.4.320

2 files

0.4.315

2 files

0.4.313

2 files

0.4.311

2 files

0.4.309

2 files

0.4.303

2 files

0.4.300

2 files

0.4.298

2 files

0.4.294

2 files

0.4.292

2 files

0.4.290

2 files

0.4.287

2 files

0.4.285

2 files

0.4.283

2 files

0.4.281

2 files

0.4.279

2 files

0.4.277

2 files

0.4.275

2 files

0.4.273

2 files

0.4.271

2 files

0.4.268

2 files

0.4.266

2 files

0.4.264

2 files

0.4.258

2 files

0.4.254

2 files

0.4.252

2 files

0.4.250

2 files

0.4.247

2 files

0.4.244

2 files

0.4.242

2 files

0.4.239

2 files

0.4.237

2 files

0.4.232

2 files

0.4.229

2 files

0.4.227

2 files

0.4.224

2 files

0.4.222

2 files

0.4.220

2 files

0.4.218

2 files

0.4.215

2 files

0.4.212

2 files

0.4.210

2 files

0.4.208

2 files

0.4.204

2 files

0.4.201

2 files

0.4.199

2 files

0.4.189

2 files

0.4.187

2 files

0.4.184

2 files

0.4.182

2 files

0.4.180

2 files

0.4.178

2 files

0.4.176

2 files

0.4.170

2 files

0.4.168

2 files

0.4.166

2 files

0.4.164

2 files

0.4.162

2 files

0.4.160

2 files

0.4.158

2 files

0.4.156

2 files

0.4.153

2 files

0.4.151

2 files

0.4.149

2 files

0.4.146

2 files

0.4.144

2 files

0.4.142

2 files

0.4.140

2 files

0.4.137

2 files

0.4.135

2 files

0.4.133

1 file

0.4.130

2 files

0.4.126

2 files

0.4.124

2 files

0.4.122

2 files

0.4.115

2 files

0.4.110

2 files

0.4.108

2 files

0.4.98

2 files

0.4.96

2 files

0.4.93

2 files

0.4.90

2 files

0.4.86

2 files

0.4.84

2 files

0.4.81

2 files

0.4.78

2 files

0.4.72

2 files

0.4.70

2 files

0.4.64

2 files

0.4.61

2 files

0.4.59

2 files

0.4.51

2 files

0.4.49

2 files

0.4.47

2 files

0.4.44

2 files

0.4.42

2 files

0.4.40

2 files

0.4.38

2 files

0.3.7

2 files

0.3.5

2 files

0.1.36

2 files

0.1.34

2 files

0.1.32

2 files

0.1.28

2 files

0.1.25

2 files

0.1.23

2 files

0.1.19

2 files

0.1.13

2 files

0.1.9

2 files

0.1.5

2 files

0.1.3

2 files

0.1.1

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page