Skip to main content

Utilities to convert python data to latex tables.

Project description

CI Codecov Code style: black

pytextable creates well-formatted latex tables with booktabs support in pure python.

pytextable is highly-configurable, you decide how your table should look.

pytextable is small, fast and requires nothing but python>=3.6.

Quick Start Guide

  1. Install

    pip install pytextable
    
  2. Import

    import pytextable
    
  3. Create a latex table from your data :)

    pytextable.write(data, "table.tex")
    

Example

import pytextable

# This is usually your 2d numpy array or any sequence of sequences
DATA = [[1.2346, 1, 1.2346], [1.2346, 1.2346, 1.2346], [1.2346, 1.2346, 1.2346]]

>>> pytextable.tostring(
    DATA,
    fmt=".3f",
    header=("first", "second", "third"),
    caption="My fancy pytextable",
    label="tab:pytextable",
)
r"""
\begin{table}
    \centering
    \caption{My fancy pytextable}
    \label{tab:pytextable}
    \begin{tabular}{ccc}
        \toprule
        first & second & third \\
        \midrule
        1.235 & 1.000 & 1.235 \\
        1.235 & 1.235 & 1.235 \\
        1.235 & 1.235 & 1.235 \\
        \bottomrule
    \end{tabular}
\end{table}
"""

# To write to file use pytextable.write(DATA, filename)
>>> pytextable.write(DATA, "table.tex", fmt=".3f", ...)

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Project details


Release history Release notifications

Download files

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

Files for pytextable, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytextable-0.1.0-py3-none-any.whl (18.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pytextable-0.1.0.tar.gz (20.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page