Reading -sv files and writing them to dataframes
Project description
py-xsv
py-xsv is a Python utility for reading -SV files (CSV, TSV, etc.) and converting them into dataframes.
Features
- Auto-detect delimiters in CSV, TSV, or other -SV files.
- Read files into:
- List of dictionaries (
content_dict) - List of lists (
content_list)
- List of dictionaries (
- Extract column data easily (
column). - Quickly access top/bottom rows (
head,tail). - Get dimensions (
length_width) and headers (headers). - Save -SV file to pandas DataFrames (
save_df).
Installation
pip install py-xsv
This needs Python 3.9 or more.
Docs
Read a CSV/TSV file as a list of dictionaries
import py_xsv
data = content_dict("data.csv")
print(data[:5])
Read as a list of lists
import py_xsv
data = content_list("data.csv")
print(data[:5])
Detect dilimiter manualy
import py_xsv
with open("data.csv", "r") as f:
lines = f.readlines()
delimiter = detect_delimiter(lines)
print(f"Detected delimiter: {delimiter}")
Work with columns and headers
import py_xsv
data = content_dict("data.csv")
print("Headers:", headers(data))
print("First column:", column(data, "ColumnName"))
Quick access to top and bottom rows
import py_xsv
data = content_list("data.csv")
print("Top 5 rows:", head(data, 5))
print("Bottom 5 rows:", tail(data, 5))
Save data to a pandas DataFrame
import pandas
import py_xsv
data = content_dict("data.csv")
df = save_df(data)
You need to have
import pandasbefore doing this
Exceptions
NotSVFileError- Used when a non -sv file is givenPandaError- Errors while using pandasError- Generic Error
License
This is licensed under the WTFPL.
This means that you have permission for:
- Commercial use
- Modification
- Distribution
- Private use
- Everything basically
Under no conditions or limitations
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_xsv-0.0.1.tar.gz.
File metadata
- Download URL: py_xsv-0.0.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
770724f83296e21cfd796932d6d28229dbe4626b0a450b834eb37931e7277a17
|
|
| MD5 |
9885b0809e8352209899ec8e467486b3
|
|
| BLAKE2b-256 |
7e3dcdbb3c4463dd7e93c9a5edba37a9f01965baff265d316d144c9127d51f17
|
File details
Details for the file py_xsv-0.0.1-py3-none-any.whl.
File metadata
- Download URL: py_xsv-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b273739700f377bb2f7c6e9ca652fae466e1ef770393b0b4cdbaef87b90530c8
|
|
| MD5 |
668967cb88f40669845a0fde9a275f49
|
|
| BLAKE2b-256 |
4dcda8253a5b14488f3100c3e4a2693f80311820713ecc6cd97d27a3cef6439e
|