Skip to main content

🌽💪 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()

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

Download files

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

Source Distribution

cornflex-1.1.5.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

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

cornflex-1.1.5-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file cornflex-1.1.5.tar.gz.

File metadata

  • Download URL: cornflex-1.1.5.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for cornflex-1.1.5.tar.gz
Algorithm Hash digest
SHA256 b47c25ceb499a5214934a8a9942d44a9b396b495f93ca48d6c84bbc5ed91a68b
MD5 fdd71bd68ef3fbc3f65939c67c596222
BLAKE2b-256 d6da5906011d2d30ade4b7b2aa30c15c131b398b913839ad92703aa062b590ca

See more details on using hashes here.

File details

Details for the file cornflex-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: cornflex-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for cornflex-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1f64d1d6eea06ddc9a24528ac32f78f2b002d08ae519a88a5dac53aed69d1b96
MD5 d7e5113b33096f57e5e6d5663a3cb0d7
BLAKE2b-256 b4cdb0637ebb9b2fe578f2180462885c9823def33afb27459aa6541caf3874c8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

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