dataframe-textual 1.2.0__tar.gz → 1.3.9__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-1.2.0 → dataframe_textual-1.3.9}/PKG-INFO +46 -6
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/README.md +44 -4
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/pyproject.toml +3 -2
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/common.py +33 -12
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/data_frame_help_panel.py +6 -4
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/data_frame_table.py +256 -172
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/data_frame_viewer.py +19 -27
- dataframe_textual-1.3.9/src/dataframe_textual/sql_screen.py +202 -0
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/table_screen.py +13 -17
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/yes_no_screen.py +9 -5
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/uv.lock +292 -3
- dataframe_textual-1.2.0/.python-version +0 -1
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/.gitignore +0 -0
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/LICENSE +0 -0
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/main.py +0 -0
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/__init__.py +0 -0
- {dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/__main__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataframe-textual
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.9
|
|
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
|
|
@@ -29,7 +29,7 @@ Classifier: Topic :: Utilities
|
|
|
29
29
|
Classifier: Typing :: Typed
|
|
30
30
|
Requires-Python: >=3.11
|
|
31
31
|
Requires-Dist: polars>=1.34.0
|
|
32
|
-
Requires-Dist: textual>=6.5.0
|
|
32
|
+
Requires-Dist: textual[syntax]>=6.5.0
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: textual-dev>=1.8.0; extra == 'dev'
|
|
35
35
|
Provides-Extra: excel
|
|
@@ -161,7 +161,7 @@ When multiple files are opened:
|
|
|
161
161
|
|-----|--------|
|
|
162
162
|
| `Ctrl+O` | Open file in a new tab |
|
|
163
163
|
| `Ctrl+W` | Close current tab |
|
|
164
|
-
| `Ctrl+
|
|
164
|
+
| `Ctrl+A` | Save all open tabs to Excel file |
|
|
165
165
|
| `>` or `b` | Move to next tab |
|
|
166
166
|
| `<` | Move to previous tab |
|
|
167
167
|
| `B` | Toggle tab bar visibility |
|
|
@@ -171,7 +171,7 @@ When multiple files are opened:
|
|
|
171
171
|
|
|
172
172
|
| Key | Action |
|
|
173
173
|
|-----|--------|
|
|
174
|
-
| `
|
|
174
|
+
| `F1` | Toggle help panel |
|
|
175
175
|
| `k` | Cycle through themes |
|
|
176
176
|
|
|
177
177
|
---
|
|
@@ -213,7 +213,7 @@ When multiple files are opened:
|
|
|
213
213
|
| `A` | Add column with name and value/expression |
|
|
214
214
|
| `-` (minus) | Delete current column |
|
|
215
215
|
| `_` (underscore) | Delete current column and all columns after |
|
|
216
|
-
| `Ctrl
|
|
216
|
+
| `Ctrl+_` | Delete current column and all columns before |
|
|
217
217
|
| `x` | Delete current row |
|
|
218
218
|
| `X` | Delete current row and all rows below |
|
|
219
219
|
| `Ctrl+X` | Delete current row and all rows above |
|
|
@@ -241,6 +241,13 @@ When multiple files are opened:
|
|
|
241
241
|
| `v` | View only rows by selected rows and/or matches or cursor value |
|
|
242
242
|
| `V` | View only rows by expression |
|
|
243
243
|
|
|
244
|
+
#### SQL Interface
|
|
245
|
+
|
|
246
|
+
| Key | Action |
|
|
247
|
+
|-----|--------|
|
|
248
|
+
| `l` | Simple SQL interface (select columns & WHERE clause) |
|
|
249
|
+
| `L` | Advanced SQL interface (full SQL queries) |
|
|
250
|
+
|
|
244
251
|
#### Find & Replace
|
|
245
252
|
|
|
246
253
|
| Key | Action |
|
|
@@ -703,7 +710,40 @@ Press `@` to make URLs in the current column clickable:
|
|
|
703
710
|
- **Scans** all cells in the current column for URLs starting with `http://` or `https://`
|
|
704
711
|
- **Applies** link styling to make them clickable and dataframe remains unchanged
|
|
705
712
|
|
|
706
|
-
### 19.
|
|
713
|
+
### 19. SQL Interface
|
|
714
|
+
|
|
715
|
+
The SQL interface provides two modes for querying your dataframe:
|
|
716
|
+
|
|
717
|
+
#### Simple SQL Interface (`l`)
|
|
718
|
+
Select specific columns and apply WHERE conditions without writing full SQL:
|
|
719
|
+
- Choose which columns to include in results
|
|
720
|
+
- Specify WHERE clause for filtering
|
|
721
|
+
- Ideal for quick filtering and column selection
|
|
722
|
+
|
|
723
|
+
#### Advanced SQL Interface (`L`)
|
|
724
|
+
Execute complete SQL queries for advanced data manipulation:
|
|
725
|
+
- Write full SQL queries with standard [SQL syntax](https://docs.pola.rs/api/python/stable/reference/sql/index.html)
|
|
726
|
+
- Support for JOINs, GROUP BY, aggregations, and more
|
|
727
|
+
- Access to all SQL capabilities for complex transformations
|
|
728
|
+
- Always use `self` as the table name
|
|
729
|
+
|
|
730
|
+
**Examples:**
|
|
731
|
+
```sql
|
|
732
|
+
-- Filter and select specific rows and/or columns
|
|
733
|
+
SELECT name, age FROM self WHERE age > 30
|
|
734
|
+
|
|
735
|
+
-- Aggregate with GROUP BY
|
|
736
|
+
SELECT department, COUNT(*) as count, AVG(salary) as avg_salary
|
|
737
|
+
FROM self
|
|
738
|
+
GROUP BY department
|
|
739
|
+
|
|
740
|
+
-- Complex filtering with multiple conditions
|
|
741
|
+
SELECT *
|
|
742
|
+
FROM self
|
|
743
|
+
WHERE (age > 25 AND salary > 50000) OR department = 'Management'
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### 20. Clipboard Operations
|
|
707
747
|
|
|
708
748
|
Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux
|
|
709
749
|
|
|
@@ -122,7 +122,7 @@ When multiple files are opened:
|
|
|
122
122
|
|-----|--------|
|
|
123
123
|
| `Ctrl+O` | Open file in a new tab |
|
|
124
124
|
| `Ctrl+W` | Close current tab |
|
|
125
|
-
| `Ctrl+
|
|
125
|
+
| `Ctrl+A` | Save all open tabs to Excel file |
|
|
126
126
|
| `>` or `b` | Move to next tab |
|
|
127
127
|
| `<` | Move to previous tab |
|
|
128
128
|
| `B` | Toggle tab bar visibility |
|
|
@@ -132,7 +132,7 @@ When multiple files are opened:
|
|
|
132
132
|
|
|
133
133
|
| Key | Action |
|
|
134
134
|
|-----|--------|
|
|
135
|
-
| `
|
|
135
|
+
| `F1` | Toggle help panel |
|
|
136
136
|
| `k` | Cycle through themes |
|
|
137
137
|
|
|
138
138
|
---
|
|
@@ -174,7 +174,7 @@ When multiple files are opened:
|
|
|
174
174
|
| `A` | Add column with name and value/expression |
|
|
175
175
|
| `-` (minus) | Delete current column |
|
|
176
176
|
| `_` (underscore) | Delete current column and all columns after |
|
|
177
|
-
| `Ctrl
|
|
177
|
+
| `Ctrl+_` | Delete current column and all columns before |
|
|
178
178
|
| `x` | Delete current row |
|
|
179
179
|
| `X` | Delete current row and all rows below |
|
|
180
180
|
| `Ctrl+X` | Delete current row and all rows above |
|
|
@@ -202,6 +202,13 @@ When multiple files are opened:
|
|
|
202
202
|
| `v` | View only rows by selected rows and/or matches or cursor value |
|
|
203
203
|
| `V` | View only rows by expression |
|
|
204
204
|
|
|
205
|
+
#### SQL Interface
|
|
206
|
+
|
|
207
|
+
| Key | Action |
|
|
208
|
+
|-----|--------|
|
|
209
|
+
| `l` | Simple SQL interface (select columns & WHERE clause) |
|
|
210
|
+
| `L` | Advanced SQL interface (full SQL queries) |
|
|
211
|
+
|
|
205
212
|
#### Find & Replace
|
|
206
213
|
|
|
207
214
|
| Key | Action |
|
|
@@ -664,7 +671,40 @@ Press `@` to make URLs in the current column clickable:
|
|
|
664
671
|
- **Scans** all cells in the current column for URLs starting with `http://` or `https://`
|
|
665
672
|
- **Applies** link styling to make them clickable and dataframe remains unchanged
|
|
666
673
|
|
|
667
|
-
### 19.
|
|
674
|
+
### 19. SQL Interface
|
|
675
|
+
|
|
676
|
+
The SQL interface provides two modes for querying your dataframe:
|
|
677
|
+
|
|
678
|
+
#### Simple SQL Interface (`l`)
|
|
679
|
+
Select specific columns and apply WHERE conditions without writing full SQL:
|
|
680
|
+
- Choose which columns to include in results
|
|
681
|
+
- Specify WHERE clause for filtering
|
|
682
|
+
- Ideal for quick filtering and column selection
|
|
683
|
+
|
|
684
|
+
#### Advanced SQL Interface (`L`)
|
|
685
|
+
Execute complete SQL queries for advanced data manipulation:
|
|
686
|
+
- Write full SQL queries with standard [SQL syntax](https://docs.pola.rs/api/python/stable/reference/sql/index.html)
|
|
687
|
+
- Support for JOINs, GROUP BY, aggregations, and more
|
|
688
|
+
- Access to all SQL capabilities for complex transformations
|
|
689
|
+
- Always use `self` as the table name
|
|
690
|
+
|
|
691
|
+
**Examples:**
|
|
692
|
+
```sql
|
|
693
|
+
-- Filter and select specific rows and/or columns
|
|
694
|
+
SELECT name, age FROM self WHERE age > 30
|
|
695
|
+
|
|
696
|
+
-- Aggregate with GROUP BY
|
|
697
|
+
SELECT department, COUNT(*) as count, AVG(salary) as avg_salary
|
|
698
|
+
FROM self
|
|
699
|
+
GROUP BY department
|
|
700
|
+
|
|
701
|
+
-- Complex filtering with multiple conditions
|
|
702
|
+
SELECT *
|
|
703
|
+
FROM self
|
|
704
|
+
WHERE (age > 25 AND salary > 50000) OR department = 'Management'
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### 20. Clipboard Operations
|
|
668
708
|
|
|
669
709
|
Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux
|
|
670
710
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dataframe-textual"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.9"
|
|
8
8
|
description = "Interactive terminal viewer/editor for tabular data"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -34,7 +34,7 @@ classifiers = [
|
|
|
34
34
|
]
|
|
35
35
|
dependencies = [
|
|
36
36
|
"polars>=1.34.0",
|
|
37
|
-
"textual>=6.5.0",
|
|
37
|
+
"textual[syntax]>=6.5.0",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
[project.urls]
|
|
@@ -69,4 +69,5 @@ dev = [
|
|
|
69
69
|
]
|
|
70
70
|
|
|
71
71
|
[project.scripts]
|
|
72
|
+
dataframe-textual = "dataframe_textual.__main__:main"
|
|
72
73
|
dv = "dataframe_textual.__main__:main"
|
|
@@ -133,7 +133,7 @@ def format_float(value: float, thousand_separator: bool = False, precision: int
|
|
|
133
133
|
return f"{value:,f}" if thousand_separator else str(value)
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
def format_row(vals, dtypes, apply_justify=True, thousand_separator=False) -> list[Text]:
|
|
136
|
+
def format_row(vals, dtypes, styles=None, apply_justify=True, thousand_separator=False) -> list[Text]:
|
|
137
137
|
"""Format a single row with proper styling and justification.
|
|
138
138
|
|
|
139
139
|
Converts raw row values to formatted Rich Text objects with appropriate
|
|
@@ -149,7 +149,7 @@ def format_row(vals, dtypes, apply_justify=True, thousand_separator=False) -> li
|
|
|
149
149
|
"""
|
|
150
150
|
formatted_row = []
|
|
151
151
|
|
|
152
|
-
for val, dtype in zip(vals, dtypes, strict=True):
|
|
152
|
+
for idx, (val, dtype) in enumerate(zip(vals, dtypes, strict=True)):
|
|
153
153
|
dc = DtypeConfig(dtype)
|
|
154
154
|
|
|
155
155
|
# Format the value
|
|
@@ -165,7 +165,7 @@ def format_row(vals, dtypes, apply_justify=True, thousand_separator=False) -> li
|
|
|
165
165
|
formatted_row.append(
|
|
166
166
|
Text(
|
|
167
167
|
text_val,
|
|
168
|
-
style=dc.style,
|
|
168
|
+
style=styles[idx] if styles and styles[idx] else dc.style,
|
|
169
169
|
justify=dc.justify if apply_justify else "",
|
|
170
170
|
)
|
|
171
171
|
)
|
|
@@ -216,7 +216,7 @@ def get_next_item(lst: list[Any], current, offset=1) -> Any:
|
|
|
216
216
|
return lst[next_index]
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
def parse_polars_expression(expression: str,
|
|
219
|
+
def parse_polars_expression(expression: str, columns: list[str], current_col_idx: int) -> str:
|
|
220
220
|
"""Parse and convert an expression to Polars syntax.
|
|
221
221
|
|
|
222
222
|
Replaces column references with Polars col() expressions:
|
|
@@ -234,7 +234,7 @@ def parse_polars_expression(expression: str, df: pl.DataFrame, current_col_idx:
|
|
|
234
234
|
|
|
235
235
|
Args:
|
|
236
236
|
expression: The input expression as a string.
|
|
237
|
-
|
|
237
|
+
columns: The list of column names in the DataFrame.
|
|
238
238
|
current_col_idx: The index of the currently selected column (0-based). Used for $_ reference.
|
|
239
239
|
|
|
240
240
|
Returns:
|
|
@@ -264,19 +264,19 @@ def parse_polars_expression(expression: str, df: pl.DataFrame, current_col_idx:
|
|
|
264
264
|
|
|
265
265
|
if col_ref == "_":
|
|
266
266
|
# Current selected column
|
|
267
|
-
col_name =
|
|
267
|
+
col_name = columns[current_col_idx]
|
|
268
268
|
elif col_ref == "#":
|
|
269
269
|
# RIDX is used to store 0-based row index; add 1 for 1-based index
|
|
270
270
|
return f"(pl.col('{RIDX}') + 1)"
|
|
271
271
|
elif col_ref.isdigit():
|
|
272
272
|
# Column by 1-based index
|
|
273
273
|
col_idx = int(col_ref) - 1
|
|
274
|
-
if col_idx < 0 or col_idx >= len(
|
|
274
|
+
if col_idx < 0 or col_idx >= len(columns):
|
|
275
275
|
raise ValueError(f"Column index out of range: ${col_ref}")
|
|
276
|
-
col_name =
|
|
276
|
+
col_name = columns[col_idx]
|
|
277
277
|
else:
|
|
278
278
|
# Column by name
|
|
279
|
-
if col_ref not in
|
|
279
|
+
if col_ref not in columns:
|
|
280
280
|
raise ValueError(f"Column not found: ${col_ref}")
|
|
281
281
|
col_name = col_ref
|
|
282
282
|
|
|
@@ -305,7 +305,7 @@ def tentative_expr(term: str) -> bool:
|
|
|
305
305
|
return False
|
|
306
306
|
|
|
307
307
|
|
|
308
|
-
def validate_expr(term: str,
|
|
308
|
+
def validate_expr(term: str, columns: list[str], current_col_idx: int) -> pl.Expr | None:
|
|
309
309
|
"""Validate and return the expression.
|
|
310
310
|
|
|
311
311
|
Parses a user-provided expression string and validates it as a valid Polars expression.
|
|
@@ -313,7 +313,7 @@ def validate_expr(term: str, df: pl.DataFrame, current_col_idx: int) -> pl.Expr
|
|
|
313
313
|
|
|
314
314
|
Args:
|
|
315
315
|
term: The input expression as a string.
|
|
316
|
-
|
|
316
|
+
columns: The list of column names in the DataFrame.
|
|
317
317
|
current_col_idx: The index of the currently selected column (0-based). Used for $_ reference.
|
|
318
318
|
|
|
319
319
|
Returns:
|
|
@@ -326,7 +326,7 @@ def validate_expr(term: str, df: pl.DataFrame, current_col_idx: int) -> pl.Expr
|
|
|
326
326
|
|
|
327
327
|
try:
|
|
328
328
|
# Parse the expression
|
|
329
|
-
expr_str = parse_polars_expression(term,
|
|
329
|
+
expr_str = parse_polars_expression(term, columns, current_col_idx)
|
|
330
330
|
|
|
331
331
|
# Validate by evaluating it
|
|
332
332
|
try:
|
|
@@ -440,6 +440,9 @@ def load_file(
|
|
|
440
440
|
sources.append((lf, filename, filepath.stem))
|
|
441
441
|
else:
|
|
442
442
|
ext = filepath.suffix.lower()
|
|
443
|
+
if ext == ".gz" or ext == ".bz2" or ext == ".xz":
|
|
444
|
+
ext = filepath.with_suffix("").suffix.lower()
|
|
445
|
+
|
|
443
446
|
if ext == ".csv":
|
|
444
447
|
file_format = "csv"
|
|
445
448
|
elif ext in (".xlsx", ".xls"):
|
|
@@ -459,3 +462,21 @@ def load_file(
|
|
|
459
462
|
sources.extend(load_file(filename, first_sheet, prefix_sheet, file_format, has_header))
|
|
460
463
|
|
|
461
464
|
return sources
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def now() -> str:
|
|
468
|
+
"""Get the current local time as a formatted string."""
|
|
469
|
+
import time
|
|
470
|
+
|
|
471
|
+
return time.strftime("%m/%d/%Y %H:%M:%S", time.localtime())
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
async def sleep_async(seconds: float) -> None:
|
|
475
|
+
"""Async sleep to yield control back to the event loop.
|
|
476
|
+
|
|
477
|
+
Args:
|
|
478
|
+
seconds: The number of seconds to sleep.
|
|
479
|
+
"""
|
|
480
|
+
import asyncio
|
|
481
|
+
|
|
482
|
+
await asyncio.sleep(seconds)
|
{dataframe_textual-1.2.0 → dataframe_textual-1.3.9}/src/dataframe_textual/data_frame_help_panel.py
RENAMED
|
@@ -79,10 +79,12 @@ class DataFrameHelpPanel(Widget):
|
|
|
79
79
|
None
|
|
80
80
|
"""
|
|
81
81
|
|
|
82
|
-
def update_help(focused_widget: Widget | None):
|
|
83
|
-
|
|
82
|
+
# def update_help(focused_widget: Widget | None):
|
|
83
|
+
# self.update_help(focused_widget)
|
|
84
84
|
|
|
85
|
-
self.watch(self.screen, "focused", update_help)
|
|
85
|
+
# self.watch(self.screen, "focused", update_help)
|
|
86
|
+
|
|
87
|
+
self.update_help(self.screen.focused)
|
|
86
88
|
|
|
87
89
|
def update_help(self, focused_widget: Widget | None) -> None:
|
|
88
90
|
"""Update the help for the focused widget.
|
|
@@ -96,7 +98,7 @@ class DataFrameHelpPanel(Widget):
|
|
|
96
98
|
return
|
|
97
99
|
self.set_class(focused_widget is not None, "-show-help")
|
|
98
100
|
if focused_widget is not None:
|
|
99
|
-
help = self.app.HELP + "\n" + focused_widget.HELP or ""
|
|
101
|
+
help = (self.app.HELP or "") + "\n" + (focused_widget.HELP or "")
|
|
100
102
|
if not help:
|
|
101
103
|
self.remove_class("-show-help")
|
|
102
104
|
try:
|