Skip to main content

DataFrame generation, CSV/HTML/chart export, and template rendering for numpy arrays and FieldSet containers

Project description

FieldSet Export

DataFrame generation, CSV/HTML/chart export, and template rendering for numpy arrays and FieldSet containers.

pandas is optional — CSV, table, and chart exporters work with just numpy. Only StyledExporter requires pandas.

Installation

pip install vcti-fieldset-export>=1.0.0

With pandas support (for StyledExporter):

pip install vcti-fieldset-export[pandas]>=1.0.0

With all optional dependencies:

pip install vcti-fieldset-export[all]>=1.0.0

Quick Start

All exporters accept numpy arrays, dicts of numpy arrays, or pandas DataFrames.

CSV Export

import numpy as np
from vcti.fieldsetexport import CsvExporter

# From a dict of numpy arrays (no pandas needed)
CsvExporter({"stress": np.array([100, 200]), "disp": np.array([0.1, 0.2])}).export("output.csv")

# From a 2-D numpy array with field names
CsvExporter(np.array([[100, 0.1], [200, 0.2]]), field_names=["stress", "disp"]).export("output.csv")

# From a pandas DataFrame (requires pandas)
import pandas as pd
CsvExporter(pd.DataFrame({"stress": [100, 200], "disp": [0.1, 0.2]})).export("output.csv")

HTML Table (Tabulator)

from vcti.fieldsetexport import TableExporter

TableExporter({"stress": np.array([100, 200])}).export("output.html")

Styled HTML (requires pandas)

from vcti.fieldsetexport import StyledExporter

(
    StyledExporter({"stress": np.array([100, 200])})
    .set_caption("Results")
    .set_format(precision=2)
    .export_html("styled.html")
)

Interactive Chart

from vcti.fieldsetexport import ChartExporter, Trace, FigType, Fig

exporter = ChartExporter({"x": np.array([1, 2, 3])})
exporter.plot.title = "Stress vs Displacement"
exporter.plot.x_axis_title = "Index"
exporter.plot.y_axis_title = "Value"

fig = Fig(FigType.XY)
fig.add_trace(Trace("Stress", np.array([100, 200, 300]), color="blue"))
fig.add_trace(Trace("Displacement", np.array([0.1, 0.2, 0.3]), color="red"))
exporter.add_fig(fig)

exporter.export("chart.html")

Export Result and Dry-Run Validation

Every export() call returns an ExportResult with statistics:

result = CsvExporter({"stress": np.array([100, 200])}).export("output.csv")
print(result)  # ExportResult: 2 rows × 1 cols in 1.2ms, 34 bytes

# Dry-run: validate data + template without writing a file
result = CsvExporter(data).export("output.csv", validate_only=True)
assert result.dry_run is True

Error Handling

All export errors inherit from ExportError for easy catch-all handling:

from vcti.fieldsetexport import CsvExporter, ExportError, InvalidDataError

try:
    CsvExporter(data).export("output.csv")
except InvalidDataError as e:
    print(f"Bad data: {e}")       # empty array, wrong shape, etc.
except ExportError as e:
    print(f"Export failed: {e}")  # catches any export error

Exception hierarchy: ExportError > InvalidDataError, TemplateRenderError, FileWriteError.


Dependencies

Project details


Download files

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

Source Distribution

vcti_fieldset_export-1.0.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

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

vcti_fieldset_export-1.0.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file vcti_fieldset_export-1.0.0.tar.gz.

File metadata

  • Download URL: vcti_fieldset_export-1.0.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_fieldset_export-1.0.0.tar.gz
Algorithm Hash digest
SHA256 477e0dab4ff327728871740d2281c9d6c1642c6730b50656dfe1e830266bd3da
MD5 9a680fe76544e82860f0320bac5e45a3
BLAKE2b-256 a9c0f521027f061d164f418df3398bfc84609afafe78e5fd3dfbf718f1d2db04

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fieldset_export-1.0.0.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-fieldset-export

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_fieldset_export-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vcti_fieldset_export-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d53ec033a452608471c02584aade3fea9340f73de382f6e6e3b67c8e69dfd21c
MD5 4e452c6eaa865bd98506d4c627bd99f3
BLAKE2b-256 0fa40872fd2d2cbfb18146ac1afd8fe62e9f6ca41882c21959e97ee684fe7da3

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fieldset_export-1.0.0-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-fieldset-export

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page