Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

🌽💪 Cornflex 🌽💪

A lightweight SFTP reader built on top of paramiko and polars. Connects to remote servers and pulls files down as strings, Polars DataFrames, or raw text.


Installation

pip install paramiko polars chardet

Then drop cornflex/ into your project.


Usage

from cornflex import SFTPReader

Connect with password

reader = SFTPReader(
    hostname="sftp.example.com",
    username="myuser",
    password="mypassword",
)

Connect with PEM key

reader = SFTPReader(
    hostname="sftp.example.com",
    username="myuser",
    pem_file="/path/to/key.pem",
)

Methods

get_files(remote_path, file_pattern)

Lists files in a remote directory. Supports glob-style patterns.

reader.get_files(remote_path="/data", file_pattern="*.csv")
# ["orders_2024.csv", "users_2024.csv"]

get_csv_file(file_name, remote_path, column_names)

Fetches a CSV and returns it as a Polars DataFrame.

reader.connect()
df = reader.get_csv_file("orders.csv", remote_path="/data")

# Override column names (useful when file has no header)
df = reader.get_csv_file("orders.csv", remote_path="/data", column_names=["id", "amount", "date"])
reader.close()

open_file(file_name, remote_path)

Yields a remote file as a binary stream, so a large file can be parsed as it arrives instead of loaded whole. At most max_requests blocks (default 32) are read ahead, which keeps the buffer small. Errors are raised, and the file closes when the block ends.

import xml.etree.ElementTree as ET

with reader.open_file("feed.xml", remote_path="/exports") as file:
    for _, element in ET.iterparse(file, events=("end",)):
        ...

get_xml_file_to_string(file_name, remote_path)

Fetches an XML file and returns it as a string.

reader.connect()
xml = reader.get_xml_file_to_string("feed.xml", remote_path="/exports")
reader.close()

file_to_string(file_name, remote_path, encoding)

Fetches any file as a string. Auto-detects encoding via chardet if not specified.

reader.connect()
content = reader.file_to_string("report.txt", remote_path="/reports")

# Force encoding
content = reader.file_to_string("report.txt", encoding="latin-1")
reader.close()

Notes

  • get_files() handles connect/close internally.
  • For all other methods, call connect() before and close() after.
  • Either password or pem_file must be provided — not both, not neither.
  • get_csv_file assumes UTF-8. Use file_to_string for other encodings.

Dependencies

Package Purpose
paramiko SSH/SFTP connection
polars DataFrame output
chardet Encoding detection

Metadata

Release files for cornflex 1.3.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cornflex 1.3.0rc1
File Size Uploaded Provenance Actions
cornflex-1.3.0rc1.tar.gz 38.0 kB Without provenance Details for cornflex-1.3.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cornflex 1.3.0rc1
File Interpreter ABI Platform Actions
cornflex-1.3.0rc1-py3-none-any.whl Python 3 none any Details for cornflex-1.3.0rc1-py3-none-any.whl

Total release size: 43.9 kB

Release files / cornflex-1.3.0rc1.tar.gz

Download URL cornflex-1.3.0rc1.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5ba549c26a522a23720b8809d6aad55d5320e40ed7a0b0554d5d11d3c6512ce4
BLAKE2b-256 checksum
How to use checksums
6a059e7989d7c5597d5034da5cd8cc1230f1b8b45454a167f8c05ceb2b992563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / cornflex-1.3.0rc1-py3-none-any.whl

Download URL cornflex-1.3.0rc1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9c360326f14d01e7a72622799b60b55e4fdd1648d386144665e1c74981c22c0
BLAKE2b-256 checksum
How to use checksums
0502905c5ce7af6994988068fa672e956e010e095d29cb7b8f83aa477c20d094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for cornflex 1.3.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page