Write text or tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.
Project description
Flexout
A Python library to write text or tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.
The output file may be on the local file system or on a Windows/Samba share (including when the library is used on Linux).
Installation
Install with all optional dependencies:
pip install flexout[all]
Optional dependencies may also be requested individually:
pip install flexout[tabulate,excel,smb]
Usage
Export text to stdout or to a file:
from flexout import Flexout
with Flexout(filename or "stdout") as o:
o.file.write("Content")
Export tabular data to stdout or to a file:
from flexout import Flexout
with Flexout(filename or "stdout") as o:
o.append_headers("Id", "Word")
o.append_row(1, "Hello")
o.append_row(2, "World")
If filename
has extension with .xlsx
, output will be in Excel 2010 format.
Otherwise it will be in CSV format.
If filename
starts with \\
, output will be done on the corresponding Windows/Samba share.
To indicate Samba credentials, call configure_smb_credentials
before using class Flexout
.
Example:
from flexout import Flexout, configure_smb_credentials
configure_smb_credentials(user=..., password=...)
with Flexout(r"\\server\share\path\to\file") as o:
...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.