dataframe-textual 2.34.0__tar.gz → 2.35.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/PKG-INFO +10 -4
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/README.md +9 -3
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/pyproject.toml +1 -1
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/__main__.py +20 -1
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/common.py +43 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/uv.lock +1 -1
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/.gitignore +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/LICENSE +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/main.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/__init__.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_help_panel.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_table.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_viewer.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/file_picker_screen.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/loading_screen.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/table_screen.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/theme_screen.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/yes_no_screen.py +0 -0
- {dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/xbk/common.py_w_compute_error +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataframe-textual
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.35.0
|
|
4
4
|
Summary: Interactive terminal viewer/editor for tabular data
|
|
5
5
|
Project-URL: Homepage, https://github.com/need47/dataframe-textual
|
|
6
6
|
Project-URL: Repository, https://github.com/need47/dataframe-textual.git
|
|
@@ -152,7 +152,8 @@ When multiple files are opened:
|
|
|
152
152
|
## Command Line Options
|
|
153
153
|
|
|
154
154
|
```
|
|
155
|
-
usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-L N] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]] [--all-in-one]
|
|
155
|
+
usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-L [N]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]] [--all-in-one]
|
|
156
|
+
[--sql SQL] [-o OUTPUT]
|
|
156
157
|
[files ...]
|
|
157
158
|
|
|
158
159
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -169,7 +170,7 @@ options:
|
|
|
169
170
|
When used without values, list available fields. Otherwise, read only specified fields.
|
|
170
171
|
-H, --header [HEADER ...]
|
|
171
172
|
Specify header info. When reading CSV/TSV. If used without values, assumes no header. Otherwise, use provided values as column header (e.g., `-H col1 col2 col3`).
|
|
172
|
-
-L, --infer_schema_length N
|
|
173
|
+
-L, --infer_schema_length [N]
|
|
173
174
|
Number of rows to use for inferring schema when reading CSV/TSV. Defaults to 100. When used without value, uses all rows for schema inference (can be slow for large files).
|
|
174
175
|
-I, --no-inference Do not infer data types when reading CSV/TSV
|
|
175
176
|
-T, --truncate-ragged-lines
|
|
@@ -185,8 +186,10 @@ options:
|
|
|
185
186
|
-N, --null NULL [NULL ...]
|
|
186
187
|
Values to interpret as null values when reading CSV/TSV
|
|
187
188
|
--theme [THEME] Set the theme for the application. If used without value, show available themes.
|
|
188
|
-
--all-in-one, --aio
|
|
189
|
+
--all-in-one, --aio, --one
|
|
190
|
+
Read all files (must be of same format and same structure) into one single table.
|
|
189
191
|
--sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
|
|
192
|
+
-o, --output OUTPUT Output file (optionally modified) with specified format, which is inferred from file extension (e.g., .csv, .xlsx).
|
|
190
193
|
```
|
|
191
194
|
|
|
192
195
|
### CLI Examples
|
|
@@ -248,6 +251,9 @@ dv data-1.csv data-2.csv --all-in-one
|
|
|
248
251
|
|
|
249
252
|
# Filter data using SQL query (use 'self' as the table name)
|
|
250
253
|
dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
|
|
254
|
+
|
|
255
|
+
# Convert to other format
|
|
256
|
+
dv data.csv -o data.parquet
|
|
251
257
|
```
|
|
252
258
|
|
|
253
259
|
## Keyboard Shortcuts
|
|
@@ -113,7 +113,8 @@ When multiple files are opened:
|
|
|
113
113
|
## Command Line Options
|
|
114
114
|
|
|
115
115
|
```
|
|
116
|
-
usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-L N] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]] [--all-in-one]
|
|
116
|
+
usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-L [N]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]] [--all-in-one]
|
|
117
|
+
[--sql SQL] [-o OUTPUT]
|
|
117
118
|
[files ...]
|
|
118
119
|
|
|
119
120
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -130,7 +131,7 @@ options:
|
|
|
130
131
|
When used without values, list available fields. Otherwise, read only specified fields.
|
|
131
132
|
-H, --header [HEADER ...]
|
|
132
133
|
Specify header info. When reading CSV/TSV. If used without values, assumes no header. Otherwise, use provided values as column header (e.g., `-H col1 col2 col3`).
|
|
133
|
-
-L, --infer_schema_length N
|
|
134
|
+
-L, --infer_schema_length [N]
|
|
134
135
|
Number of rows to use for inferring schema when reading CSV/TSV. Defaults to 100. When used without value, uses all rows for schema inference (can be slow for large files).
|
|
135
136
|
-I, --no-inference Do not infer data types when reading CSV/TSV
|
|
136
137
|
-T, --truncate-ragged-lines
|
|
@@ -146,8 +147,10 @@ options:
|
|
|
146
147
|
-N, --null NULL [NULL ...]
|
|
147
148
|
Values to interpret as null values when reading CSV/TSV
|
|
148
149
|
--theme [THEME] Set the theme for the application. If used without value, show available themes.
|
|
149
|
-
--all-in-one, --aio
|
|
150
|
+
--all-in-one, --aio, --one
|
|
151
|
+
Read all files (must be of same format and same structure) into one single table.
|
|
150
152
|
--sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
|
|
153
|
+
-o, --output OUTPUT Output file (optionally modified) with specified format, which is inferred from file extension (e.g., .csv, .xlsx).
|
|
151
154
|
```
|
|
152
155
|
|
|
153
156
|
### CLI Examples
|
|
@@ -209,6 +212,9 @@ dv data-1.csv data-2.csv --all-in-one
|
|
|
209
212
|
|
|
210
213
|
# Filter data using SQL query (use 'self' as the table name)
|
|
211
214
|
dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
|
|
215
|
+
|
|
216
|
+
# Convert to other format
|
|
217
|
+
dv data.csv -o data.parquet
|
|
212
218
|
```
|
|
213
219
|
|
|
214
220
|
## Keyboard Shortcuts
|
|
@@ -8,7 +8,7 @@ import polars as pl
|
|
|
8
8
|
from textual.theme import BUILTIN_THEMES
|
|
9
9
|
|
|
10
10
|
from . import __version__
|
|
11
|
-
from .common import handle_compute_error, load_dataframe
|
|
11
|
+
from .common import SUPPORTED_FORMATS, convert_file, guess_file_format, handle_compute_error, load_dataframe
|
|
12
12
|
from .data_frame_viewer import DataFrameViewer
|
|
13
13
|
|
|
14
14
|
|
|
@@ -150,6 +150,7 @@ def cli() -> argparse.Namespace:
|
|
|
150
150
|
parser.add_argument(
|
|
151
151
|
"--all-in-one",
|
|
152
152
|
"--aio",
|
|
153
|
+
"--one",
|
|
153
154
|
action="store_true",
|
|
154
155
|
help="Read all files (must be of same format and same structure) into one single table.",
|
|
155
156
|
)
|
|
@@ -158,6 +159,12 @@ def cli() -> argparse.Namespace:
|
|
|
158
159
|
"--sql", help="Specify a SQL query to execute on the input file (e.g., to select and filter data)"
|
|
159
160
|
)
|
|
160
161
|
|
|
162
|
+
parser.add_argument(
|
|
163
|
+
"-o",
|
|
164
|
+
"--output",
|
|
165
|
+
help="Output file (optionally modified) with specified format, which is inferred from file extension (e.g., .csv, .xlsx).",
|
|
166
|
+
)
|
|
167
|
+
|
|
161
168
|
args = parser.parse_args()
|
|
162
169
|
|
|
163
170
|
if args.delimiter and len(args.delimiter) != 1:
|
|
@@ -208,6 +215,14 @@ def cli() -> argparse.Namespace:
|
|
|
208
215
|
def main() -> None:
|
|
209
216
|
args = cli()
|
|
210
217
|
|
|
218
|
+
if args.output:
|
|
219
|
+
if not (fmt := guess_file_format(args.output)):
|
|
220
|
+
print(
|
|
221
|
+
f"Unsupported output file format for `{args.output}`. Supported formats: {', '.join(SUPPORTED_FORMATS)}",
|
|
222
|
+
file=sys.stderr,
|
|
223
|
+
)
|
|
224
|
+
sys.exit(1)
|
|
225
|
+
|
|
211
226
|
sources = load_dataframe(
|
|
212
227
|
args.files,
|
|
213
228
|
delimiter=args.delimiter,
|
|
@@ -244,6 +259,10 @@ def main() -> None:
|
|
|
244
259
|
print(f"SQL error: {e}", file=sys.stderr)
|
|
245
260
|
sys.exit(1)
|
|
246
261
|
|
|
262
|
+
# If output file is specified, write the (optionally modified) data to the output file and exit
|
|
263
|
+
if args.output:
|
|
264
|
+
return convert_file(sources, args.output, fmt)
|
|
265
|
+
|
|
247
266
|
# Run the DataFrame Viewer application
|
|
248
267
|
app = DataFrameViewer(*sources, theme=args.theme)
|
|
249
268
|
handle_compute_error(app.run())
|
|
@@ -9,6 +9,7 @@ from pathlib import Path
|
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
11
|
import polars as pl
|
|
12
|
+
import xlsxwriter
|
|
12
13
|
from rich.text import Text
|
|
13
14
|
|
|
14
15
|
# Supported file formats
|
|
@@ -916,3 +917,45 @@ def load_file(
|
|
|
916
917
|
sys.exit(1)
|
|
917
918
|
|
|
918
919
|
return data
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
def convert_file(sources: list[Source], filename: str, fmt: str) -> None:
|
|
923
|
+
if len(sources) > 1 and fmt not in ("xlsx", "xls"):
|
|
924
|
+
print("Only Excel formats (.xlsx, .xls) support multiple tabs", file=sys.stderr)
|
|
925
|
+
sys.exit(1)
|
|
926
|
+
|
|
927
|
+
# Get rid of the RID column
|
|
928
|
+
for source in sources:
|
|
929
|
+
source.lf = source.lf.select(pl.exclude(RID))
|
|
930
|
+
|
|
931
|
+
try:
|
|
932
|
+
if fmt == "csv":
|
|
933
|
+
sources[0].lf.sink_csv(filename)
|
|
934
|
+
elif fmt == "tsv":
|
|
935
|
+
sources[0].lf.sink_csv(filename, separator="\t")
|
|
936
|
+
elif fmt == "psv":
|
|
937
|
+
sources[0].lf.sink_csv(filename, separator="|")
|
|
938
|
+
elif fmt == "parquet":
|
|
939
|
+
sources[0].lf.sink_parquet(filename)
|
|
940
|
+
elif fmt == "ndjson":
|
|
941
|
+
sources[0].lf.sink_ndjson(filename)
|
|
942
|
+
elif fmt == "json":
|
|
943
|
+
sources[0].lf.collect().write_json(filename)
|
|
944
|
+
elif fmt == "vortex":
|
|
945
|
+
import vortex as vx
|
|
946
|
+
|
|
947
|
+
vx.io.write(sources[0].lf.collect().to_arrow(), filename)
|
|
948
|
+
elif fmt in ("xlsx", "xls"):
|
|
949
|
+
if len(sources) == 1:
|
|
950
|
+
sources[0].lf.collect().write_excel(filename)
|
|
951
|
+
else:
|
|
952
|
+
with xlsxwriter.Workbook(filename) as wb:
|
|
953
|
+
for source in sources:
|
|
954
|
+
worksheet = wb.add_worksheet(source.tabname)
|
|
955
|
+
source.lf.collect().write_excel(workbook=wb, worksheet=worksheet)
|
|
956
|
+
else:
|
|
957
|
+
print(f"Unsupported output format: {fmt}. Supported formats are: {SUPPORTED_FORMATS}", file=sys.stderr)
|
|
958
|
+
sys.exit(1)
|
|
959
|
+
except Exception as e:
|
|
960
|
+
print(f"Error writing to output file: {e}", file=sys.stderr)
|
|
961
|
+
sys.exit(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_help_panel.py
RENAMED
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_table.py
RENAMED
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_viewer.py
RENAMED
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/file_picker_screen.py
RENAMED
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/loading_screen.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.34.0 → dataframe_textual-2.35.0}/src/dataframe_textual/yes_no_screen.py
RENAMED
|
File without changes
|
|
File without changes
|