dataframe-textual 2.41.0__tar.gz → 2.42.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.41.0 → dataframe_textual-2.42.0}/PKG-INFO +6 -2
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/README.md +5 -1
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/pyproject.toml +1 -1
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/__main__.py +34 -2
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/common.py +1 -1
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_table.py +12 -3
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/table_screen.py +26 -2
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/uv.lock +1 -1
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/.gitignore +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/LICENSE +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/main.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/__init__.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_help_panel.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_viewer.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/file_picker_screen.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/loading_screen.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/theme_screen.py +0 -0
- {dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/yes_no_screen.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataframe-textual
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.42.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
|
|
@@ -135,7 +135,7 @@ dv *.parquet --all-in-one
|
|
|
135
135
|
|
|
136
136
|
```
|
|
137
137
|
usage: dv [-h] [-V] [-d DELIMITER] [-f FORMAT] [-F [FIELDS ...]] [-H [HEADER ...]] [-L [N]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M [N]] [-N NULL [NULL ...]] [--theme [THEME]]
|
|
138
|
-
[--all-in-one] [--sql SQL] [-o OUTPUT]
|
|
138
|
+
[--all-in-one] [--expr EXPR] [--sql SQL] [-o OUTPUT]
|
|
139
139
|
[files ...]
|
|
140
140
|
|
|
141
141
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -173,6 +173,7 @@ options:
|
|
|
173
173
|
--theme [THEME] Set the theme for the application. If used without value, show available themes.
|
|
174
174
|
--all-in-one, --aio, --one
|
|
175
175
|
Read all files (must be of same format and same structure) into one single table.
|
|
176
|
+
--expr EXPR Specify a Polars expression to filter data (e.g., $age > 30)
|
|
176
177
|
--sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
|
|
177
178
|
-o, --output OUTPUT Output file (optionally modified) with specified format, which is inferred from file extension (e.g., .csv, .xlsx).
|
|
178
179
|
```
|
|
@@ -241,6 +242,9 @@ dv data.csv -F name age 1 -1
|
|
|
241
242
|
# Read all files (must be of same format and same structure) into one single table
|
|
242
243
|
dv data-1.csv data-2.csv --all-in-one
|
|
243
244
|
|
|
245
|
+
# Filter rows before opening the viewer using a Polars expression
|
|
246
|
+
dv data.csv --expr '$age > 30'
|
|
247
|
+
|
|
244
248
|
# Filter data using SQL query (use 'self' as the table name)
|
|
245
249
|
dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
|
|
246
250
|
|
|
@@ -96,7 +96,7 @@ dv *.parquet --all-in-one
|
|
|
96
96
|
|
|
97
97
|
```
|
|
98
98
|
usage: dv [-h] [-V] [-d DELIMITER] [-f FORMAT] [-F [FIELDS ...]] [-H [HEADER ...]] [-L [N]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M [N]] [-N NULL [NULL ...]] [--theme [THEME]]
|
|
99
|
-
[--all-in-one] [--sql SQL] [-o OUTPUT]
|
|
99
|
+
[--all-in-one] [--expr EXPR] [--sql SQL] [-o OUTPUT]
|
|
100
100
|
[files ...]
|
|
101
101
|
|
|
102
102
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -134,6 +134,7 @@ options:
|
|
|
134
134
|
--theme [THEME] Set the theme for the application. If used without value, show available themes.
|
|
135
135
|
--all-in-one, --aio, --one
|
|
136
136
|
Read all files (must be of same format and same structure) into one single table.
|
|
137
|
+
--expr EXPR Specify a Polars expression to filter data (e.g., $age > 30)
|
|
137
138
|
--sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
|
|
138
139
|
-o, --output OUTPUT Output file (optionally modified) with specified format, which is inferred from file extension (e.g., .csv, .xlsx).
|
|
139
140
|
```
|
|
@@ -202,6 +203,9 @@ dv data.csv -F name age 1 -1
|
|
|
202
203
|
# Read all files (must be of same format and same structure) into one single table
|
|
203
204
|
dv data-1.csv data-2.csv --all-in-one
|
|
204
205
|
|
|
206
|
+
# Filter rows before opening the viewer using a Polars expression
|
|
207
|
+
dv data.csv --expr '$age > 30'
|
|
208
|
+
|
|
205
209
|
# Filter data using SQL query (use 'self' as the table name)
|
|
206
210
|
dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
|
|
207
211
|
|
|
@@ -8,7 +8,15 @@ import polars as pl
|
|
|
8
8
|
from textual.theme import BUILTIN_THEMES
|
|
9
9
|
|
|
10
10
|
from . import __version__
|
|
11
|
-
from .common import
|
|
11
|
+
from .common import (
|
|
12
|
+
SUPPORTED_FORMATS,
|
|
13
|
+
guess_file_format,
|
|
14
|
+
handle_compute_error,
|
|
15
|
+
load_dataframe,
|
|
16
|
+
tentative_expr,
|
|
17
|
+
validate_expr,
|
|
18
|
+
write_file,
|
|
19
|
+
)
|
|
12
20
|
from .data_frame_viewer import DataFrameViewer
|
|
13
21
|
|
|
14
22
|
|
|
@@ -160,6 +168,8 @@ def cli() -> argparse.Namespace:
|
|
|
160
168
|
help="Read all files (must be of same format and same structure) into one single table.",
|
|
161
169
|
)
|
|
162
170
|
|
|
171
|
+
parser.add_argument("--expr", help="Specify a Polars expression to filter data (e.g., $age > 30)")
|
|
172
|
+
|
|
163
173
|
parser.add_argument(
|
|
164
174
|
"--sql", help="Specify a SQL query to execute on the input file (e.g., to select and filter data)"
|
|
165
175
|
)
|
|
@@ -245,7 +255,21 @@ def main() -> None:
|
|
|
245
255
|
|
|
246
256
|
return
|
|
247
257
|
|
|
248
|
-
if args.
|
|
258
|
+
if args.expr:
|
|
259
|
+
for source in sources:
|
|
260
|
+
columns = source.lf.collect_schema().names()
|
|
261
|
+
try:
|
|
262
|
+
expr = validate_expr(args.expr, columns)
|
|
263
|
+
except Exception as e:
|
|
264
|
+
print(f"Error validating expression [$error]{args.expr}[/]", file=sys.stderr)
|
|
265
|
+
sys.exit(1)
|
|
266
|
+
|
|
267
|
+
try:
|
|
268
|
+
source.lf = source.lf.filter(expr)
|
|
269
|
+
except pl.exceptions.ComputeError as e:
|
|
270
|
+
print(f"Error applying expression `{args.expr}`: {e}", file=sys.stderr)
|
|
271
|
+
sys.exit(1)
|
|
272
|
+
elif args.sql:
|
|
249
273
|
for source in sources:
|
|
250
274
|
ctx = pl.SQLContext(frames={"self": source.lf})
|
|
251
275
|
try:
|
|
@@ -294,6 +318,14 @@ def validate_args(args: argparse.Namespace) -> None:
|
|
|
294
318
|
)
|
|
295
319
|
sys.exit(1)
|
|
296
320
|
|
|
321
|
+
if args.expr:
|
|
322
|
+
if not tentative_expr(args.expr):
|
|
323
|
+
print(
|
|
324
|
+
f"Invalid expression: `{args.expr}`. Did you forget the `$` prefix for column references?",
|
|
325
|
+
file=sys.stderr,
|
|
326
|
+
)
|
|
327
|
+
sys.exit(1)
|
|
328
|
+
|
|
297
329
|
|
|
298
330
|
if __name__ == "__main__":
|
|
299
331
|
main()
|
|
@@ -308,7 +308,7 @@ def tentative_expr(expr: str) -> bool:
|
|
|
308
308
|
return False
|
|
309
309
|
|
|
310
310
|
|
|
311
|
-
def validate_expr(expr: str, columns: list[str], current_col_idx: int) -> pl.Expr | None:
|
|
311
|
+
def validate_expr(expr: str, columns: list[str], current_col_idx: int = 0) -> pl.Expr | None:
|
|
312
312
|
"""Validate and return the expression.
|
|
313
313
|
|
|
314
314
|
Parses a user-provided expression string and validates it as a valid Polars expression.
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_table.py
RENAMED
|
@@ -1868,9 +1868,18 @@ class DataFrameTable(DataTable):
|
|
|
1868
1868
|
"""Open a modal screen to view the selected cell's details."""
|
|
1869
1869
|
ridx = self.cursor_ridx
|
|
1870
1870
|
cidx = self.cursor_cidx
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1871
|
+
dtype = self.df.dtypes[cidx]
|
|
1872
|
+
cell_value = self.df.item(ridx, cidx)
|
|
1873
|
+
|
|
1874
|
+
# Only show cell detail screen if the value is a non-empty list, non-empty dict,
|
|
1875
|
+
# or string containing the delimiter (indicating a potential list of values).
|
|
1876
|
+
# This prevents unnecessary screens for simple scalar values.
|
|
1877
|
+
if (
|
|
1878
|
+
(dtype == pl.List and not cell_value.is_empty())
|
|
1879
|
+
or (dtype == pl.Struct and cell_value)
|
|
1880
|
+
or (dtype == pl.String and "|" in cell_value)
|
|
1881
|
+
):
|
|
1882
|
+
self.app.push_screen(CellDetailScreen(self.df, ridx, cidx))
|
|
1874
1883
|
|
|
1875
1884
|
def do_show_frequency(self, cidx: int | None = None) -> None:
|
|
1876
1885
|
"""Show frequency distribution for a given columnn."""
|
|
@@ -302,7 +302,20 @@ class RowDetailScreen(TableScreen):
|
|
|
302
302
|
self.show_statistics(self.get_cidx_name_value())
|
|
303
303
|
event.stop()
|
|
304
304
|
elif event.key == "tab":
|
|
305
|
-
|
|
305
|
+
ridx = self.ridx
|
|
306
|
+
cidx = self.table.cursor_row
|
|
307
|
+
dtype = self.dftable.df.dtypes[cidx]
|
|
308
|
+
cell_value = self.dftable.df.item(ridx, cidx)
|
|
309
|
+
|
|
310
|
+
# Only show cell detail screen if the value is a non-empty list, non-empty dict,
|
|
311
|
+
# or string containing the delimiter (indicating a potential list of values).
|
|
312
|
+
# This prevents unnecessary screens for simple scalar values.
|
|
313
|
+
if (
|
|
314
|
+
(dtype == pl.List and not cell_value.is_empty())
|
|
315
|
+
or (dtype == pl.Struct and cell_value)
|
|
316
|
+
or (dtype == pl.String and "|" in cell_value)
|
|
317
|
+
):
|
|
318
|
+
self.app.push_screen(CellDetailScreen(self.dftable.df, ridx, cidx))
|
|
306
319
|
event.stop()
|
|
307
320
|
|
|
308
321
|
def get_cidx_name_value(self) -> tuple[int, str, Any] | None:
|
|
@@ -869,5 +882,16 @@ class CellDetailScreen(TableScreen):
|
|
|
869
882
|
if event.key == "tab":
|
|
870
883
|
cidx = self.table.cursor_column
|
|
871
884
|
ridx = self.table.cursor_row
|
|
872
|
-
self.
|
|
885
|
+
dtype = self.df.dtypes[cidx]
|
|
886
|
+
cell_value = self.df.item(ridx, cidx)
|
|
887
|
+
|
|
888
|
+
# Only show cell detail screen if the value is a non-empty list, non-empty dict,
|
|
889
|
+
# or string containing the delimiter (indicating a potential list of values).
|
|
890
|
+
# This prevents unnecessary screens for simple scalar values.
|
|
891
|
+
if (
|
|
892
|
+
(dtype == pl.List and not cell_value.is_empty())
|
|
893
|
+
or (dtype == pl.Struct and cell_value)
|
|
894
|
+
or (dtype == pl.String and "|" in cell_value)
|
|
895
|
+
):
|
|
896
|
+
self.app.push_screen(CellDetailScreen(self.df, ridx, cidx))
|
|
873
897
|
event.stop()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_help_panel.py
RENAMED
|
File without changes
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/data_frame_viewer.py
RENAMED
|
File without changes
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/file_picker_screen.py
RENAMED
|
File without changes
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/loading_screen.py
RENAMED
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.41.0 → dataframe_textual-2.42.0}/src/dataframe_textual/yes_no_screen.py
RENAMED
|
File without changes
|