Skip to main content

Package to convert SVG paths to CSV data and LaTeX commands

Project description

PyPI  PyPI - Downloads  License: MIT  Static Badge 

PySvg2Csv

Amit M. Manthanwar 25 September 2025

pip install pysvg2csv

Introduction

PySvg2Csv is a package for graphic object conversion and data transformation with Python. This simple program converts graphic paths from an SVG file to a corresponding CSV data and equivalent Bézier paths used by LaTeX and PostScript.

It provides:

  • a powerful data extraction and format conversion capabilities
  • sophisticated (transformation) functions
  • tools for integrating LaTeX, PostScript, and JavaScript code

Description

The path element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. There are three different commands that can be used to create smooth curves. Two of those curves are Bézier curves, and the third is an "arc" or part of a circle. There are an infinite number of Bézier curves, but only two are available in path elements: a cubic one, called with C, and a quadratic one, called with Q. A Bézier curve is a mathematically defined, smooth curve used in computer graphics, design, and animation, determined by a set of discrete control points. These control points dictate the curve's shape, with the curve passing through the first and last points but being "pulled" toward the intermediate points. The cubic curve, C, also known as the Cubic Bézier take in two control points for each point. Therefore, to create a cubic Bézier, three sets of coordinates need to be specified. Including the starting point, there are four points for any given cubic Bézier path. The endeavor is to extract these points for every path in the SVG file and store them as CSV data and LaTeX PSTricks commands.

Quick Start

Example 1: file containing three curves

Simple Curves

from pysvg2csv.svg2csv import *

node_coords = extract_node_coordinates("data-svg/curves.svg")
print("Node Coordinates:", *node_coords, sep='\n')

latex_paths = create_latex_paths(node_coords)
print("LaTeX Paths:", *latex_paths, sep='\n')

Example 2: file containing multiple Bézier paths

Trident

from pysvg2csv.svg2csv import *

node_coords = extract_node_coordinates("data-svg/trident.svg")
print("Node Coordinates:", *node_coords, sep='\n')

latex_paths = create_latex_paths(node_coords)
print("LaTeX Paths:", *latex_paths, sep='\n')

The SVG files used in the above examples are located in the project's data folder.

Testing

PySvg2Csv requires pytest and pytest-cov. Tests can then be run after installation with any one of the following command of your choice:

pytest
pytest --cache-clear
pytest --cov=tests
pytest --cov=tests --cov-report=html:coverage_html_report

Call for Contributions

The PySvg2Csv project welcomes your expertise and enthusiasm!

Small improvements or fixes are always appreciated. If you are considering larger contributions to the source code, please contact us by emailing. through the mailing list first or join the discussions.

Writing code isn’t the only way to contribute to PySvg2Csv. You can also:

  • review pull requests
  • help us stay on top of new and old issues
  • develop tutorials, presentations, and other educational materials
  • develop graphic design for our projects and promotional materials
  • translate website content
  • help with outreach and onboard new contributors
  • write grant proposals and help with other fundraising efforts

For more information about the ways you can contribute to PySvg2CSV, visit Contribute. If you’re unsure where to start or how your skills fit in, reach out! You can ask on the mailing list or here, on GitHub, by opening a new issue or leaving a comment on a relevant issue that is already open.

We also have a biweekly community call, details of which are announced on the mailing list. You are very welcome to join.

If you are new to contributing to open source, this guide helps explain why, what, and how to successfully get involved.

Feel free to ask questions, post issues, submit pull request, and request new features.

For more information about this project and how to use this package, please check out our detailed documentation.

Languages we support

C++  Python   JavaScript  HTML5  Markdown  LaTeX

Code of Conduct

PySvg2Csv is a community-driven open source project developed by a diverse group of contributors. The PySvg2Csv leadership has made a strong commitment to creating an open, inclusive, and positive community. Please read the PySvg2Csv Code of Conduct for guidance on how to interact with others in a way that makes our community thrive.

Support this work

Support this project and its continued development, by sponsoring us!

BuyMeACoffee    Patreon   Github-sponsors

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

pysvg2csv-2025.9.25.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

pysvg2csv-2025.9.25-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pysvg2csv-2025.9.25.tar.gz.

File metadata

  • Download URL: pysvg2csv-2025.9.25.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for pysvg2csv-2025.9.25.tar.gz
Algorithm Hash digest
SHA256 f27e3b4a7daefc3791fd0a31951d87800fb06d2cdad1255178d60b685ea25586
MD5 667c9cd53e0fe2a57489c0d1235a9e44
BLAKE2b-256 4d9dfb4074db81568bbd13ba4bfe9de5bcfa56b4cb215a85211f347a194d62b1

See more details on using hashes here.

File details

Details for the file pysvg2csv-2025.9.25-py3-none-any.whl.

File metadata

  • Download URL: pysvg2csv-2025.9.25-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for pysvg2csv-2025.9.25-py3-none-any.whl
Algorithm Hash digest
SHA256 c2e19b76d0ac3dae4dfdcf05055ad041192ee3775dd1e2f35677ff4b1e846895
MD5 fa67aa7c6318c9447a011060b24fd569
BLAKE2b-256 c4e2c5048ae13296555f96917150a7766ad6b9318a3400524f14c0ad2aa1afa5

See more details on using hashes here.

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