Convert a CSV formatted input to a readable table in text
Project description
csvtables
Converts a CSV formatted input to a readable table in text. The table is Markdown compatible.
Installation
Install package using pip:
python -m pip install csvtables
Usage
You can use the package directly in the terminal or by importing it in a python script.
Command line interface
csvtables --help
Let's assume we have the following text file which is located in tests/sample_data.csv
(reference: https://en.wikipedia.org/wiki/List_of_galaxies#Closest_galaxies):
Rank,Galaxy,Distance
1,Milky Way Galaxy,0
2,Canis Major Dwarf,0.025 Mly
3,Virgo Stellar Stream,0.030 Mly
4,Sagittarius Dwarf Elliptical Galaxy,0.081 Mly
5,Large Magellanic Cloud,0.163 Mly
6,Small Magellanic Cloud,0.197 Mly
The table is generated by running:
csvtables closest_galaxies.csv
and should produce the following output:
| Rank | Galaxy | Distance |
|------|-------------------------------------|-----------|
| 1 | Milky Way Galaxy | 0 |
| 2 | Canis Major Dwarf | 0.025 Mly |
| 3 | Virgo Stellar Stream | 0.030 Mly |
| 4 | Sagittarius Dwarf Elliptical Galaxy | 0.081 Mly |
| 5 | Large Magellanic Cloud | 0.163 Mly |
| 6 | Small Magellanic Cloud | 0.197 Mly |
Running as a module
# example.py
from csvtables import csvtables
csv_file = open("tests/sample_data.csv", "r")
table = csvtables.CSVTable(csv_file)
print(table.generate_table()) # display the table to stdout
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
csvtables-0.4.0.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file csvtables-0.4.0.tar.gz
.
File metadata
- Download URL: csvtables-0.4.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e39fa1aea855805824a2073bdce6e486687b0f6203fd3ac142c2f0f46f479e |
|
MD5 | 57bf6ae85838e56e1edc655fef53a08b |
|
BLAKE2b-256 | e9b3454abdc688f986a264834ce0143a51a2b57d5d5c26d364bc4f196bd720ff |
File details
Details for the file csvtables-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: csvtables-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a902f6d2f40e4195a2a82e13d3aa5a2c468ffb66f47e90cc2503d693c1086c7c |
|
MD5 | 62ca496482577f9573c54771c2f5351e |
|
BLAKE2b-256 | a26417336cf77a16e2b79547c720784b255ba382579f0b7fc059a5067262ad33 |