dataframe-textual 1.2.0__tar.gz → 1.5.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.
Files changed (19) hide show
  1. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/PKG-INFO +250 -19
  2. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/README.md +248 -17
  3. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/pyproject.toml +3 -2
  4. dataframe_textual-1.5.0/src/dataframe_textual/__main__.py +96 -0
  5. dataframe_textual-1.5.0/src/dataframe_textual/common.py +699 -0
  6. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/data_frame_help_panel.py +6 -4
  7. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/data_frame_table.py +726 -407
  8. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/data_frame_viewer.py +28 -31
  9. dataframe_textual-1.5.0/src/dataframe_textual/sql_screen.py +202 -0
  10. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/table_screen.py +31 -20
  11. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/yes_no_screen.py +35 -11
  12. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/uv.lock +292 -3
  13. dataframe_textual-1.2.0/.python-version +0 -1
  14. dataframe_textual-1.2.0/src/dataframe_textual/__main__.py +0 -68
  15. dataframe_textual-1.2.0/src/dataframe_textual/common.py +0 -461
  16. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/.gitignore +0 -0
  17. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/LICENSE +0 -0
  18. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/main.py +0 -0
  19. {dataframe_textual-1.2.0 → dataframe_textual-1.5.0}/src/dataframe_textual/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataframe-textual
3
- Version: 1.2.0
3
+ Version: 1.5.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
@@ -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
@@ -48,7 +48,21 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/Parquet/J
48
48
  ### Data Viewing
49
49
  - 🚀 **Fast Loading** - Powered by Polars for efficient data handling
50
50
  - 🎨 **Rich Terminal UI** - Beautiful, color-coded columns with various data types (e.g., integer, float, string)
51
- - ⌨️ **Comprehensive Keyboard Navigation** - Intuitive controls for browsing, editing, and manipulating data
51
+ - ⌨️ **Comprehensive Keyboard Navigation** - Intuitive controls
52
+ # Skip first 5 lines (comments, metadata)
53
+ dv -l 5 data_with_metadata.csv
54
+
55
+ # Skip 1 row after header (e.g., units row)
56
+ dv -a 1 data_with_units.csv
57
+
58
+ # Complex CSV with comments and units row
59
+ dv -l 3 -a 1 -I messy_scientific_data.csv
60
+
61
+ # Combine all options: skip lines, skip after header, no header, no inference, gzipped
62
+ dv -l 2 -a 1 -H -I complex_data.csv.gz
63
+
64
+ # Process compressed data from stdin with line skipping
65
+ zcat compressed_data.csv.gz | dv -f csv -l 2editing, and manipulating data
52
66
  - 📊 **Flexible Input** - Read from files and/or stdin (pipes/redirects)
53
67
  - 🔄 **Smart Pagination** - Lazy load rows on demand for handling large datasets
54
68
 
@@ -64,6 +78,7 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/Parquet/J
64
78
  - 🔄 **Tab Management** - Seamlessly switch between open files with keyboard shortcuts
65
79
  - 📌 **Freeze Rows/Columns** - Keep important rows and columns visible while scrolling
66
80
  - 🎯 **Cursor Type Cycling** - Switch between cell, row, and column selection modes
81
+ - 🔗 **Link Column Creation** - Generate clickable URLs using template expressions with placeholder support
67
82
 
68
83
  ## Installation
69
84
 
@@ -129,6 +144,13 @@ uv run python main.py pokemon.csv
129
144
  # Read from stdin (auto-detects format; defaults to TSV if not recognized)
130
145
  cat data.tsv | dv
131
146
  dv < data.tsv
147
+
148
+ # Gzipped files are supported
149
+ dv data.csv.gz
150
+ dv large_dataset.tsv.gz
151
+
152
+ # Specify format for gzipped stdin
153
+ zcat data.csv.gz | dv -f csv
132
154
  ```
133
155
 
134
156
  ### Multi-File Usage - Multiple Tabs
@@ -142,6 +164,9 @@ dv file.xlsx
142
164
 
143
165
  # Mix files and stdin (read from stdin, then open file)
144
166
  dv data1.tsv < data2.tsv
167
+
168
+ # Mix regular and gzipped files
169
+ dv data1.csv data2.csv.gz data3.tsv.gz
145
170
  ```
146
171
 
147
172
  When multiple files are opened:
@@ -151,6 +176,87 @@ When multiple files are opened:
151
176
  - Close the current tab with `Ctrl+W`
152
177
  - Each file maintains its own state (edits, sort order, selections, history, etc.)
153
178
 
179
+ ## Command Line Options
180
+
181
+ ```
182
+ usage: dv [-h] [-f {csv,excel,tsv,parquet,json,ndjson}] [-H] [-I] [-E] [-c COMMENT_PREFIX] [-q QUOTE_CHAR] [-l SKIP_LINES] [-a SKIP_ROWS_AFTER_HEADER] [-u NULL [NULL ...]] [files ...]
183
+
184
+ Interactive terminal based viewer/editor for tabular data (e.g., CSV/Excel).
185
+
186
+ positional arguments:
187
+ files Files to view (or read from stdin)
188
+
189
+ options:
190
+ -h, --help show this help message and exit
191
+ -f, --format {csv,excel,tsv,parquet,json,ndjson}
192
+ Specify the format of the input files
193
+ -H, --no-header Specify that input files have no header row
194
+ -I, --no-inferrence Do not infer data types when reading CSV/TSV
195
+ -E, --ignore-errors Ignore errors when reading CSV/TSV
196
+ -c, --comment-prefix COMMENT_PREFIX
197
+ Comment lines are skipped when reading CSV/TSV (default: skip none)
198
+ -q, --quote-char QUOTE_CHAR
199
+ Quote character for reading CSV/TSV (default: "; use None to disable)
200
+ -l, --skip-lines SKIP_LINES
201
+ Skip lines when reading CSV/TSV (default: 0)
202
+ -a, --skip-rows-after-header SKIP_ROWS_AFTER_HEADER
203
+ Skip rows after header when reading CSV/TSV (default: 0)
204
+ -u, --null NULL [NULL ...]
205
+ Values to interpret as null values when reading CSV/TSV
206
+ ```
207
+
208
+ ### CLI Examples
209
+
210
+ ```bash
211
+ # View CSV file without header row
212
+ dv -H data_no_header.csv
213
+
214
+ # Disable type inference for faster loading
215
+ dv -I large_data.csv
216
+
217
+ # Ignore parsing errors in malformed CSV
218
+ dv -E data_with_errors.csv
219
+
220
+ # Skip first 3 lines of file (e.g., comments, metadata)
221
+ dv -l 3 data_with_comments.csv
222
+
223
+ # Skip 1 row after header (e.g., units row)
224
+ dv -a 1 data_with_units.csv
225
+
226
+ # Treat specific values as null/missing (e.g., 'NA', 'N/A', '-')
227
+ dv -u NA N/A - data.csv
228
+
229
+ # Multiple null values with different formats
230
+ dv -u NULL NA "" "Not Available" messy_data.csv
231
+
232
+ # Disable quote character processing for TSV with embedded quotes
233
+ dv -q "" data.tsv
234
+
235
+ # Use different quote character (e.g., single quote for CSV)
236
+ dv -q "'" data.csv
237
+
238
+ # Complex CSV with comments and units row
239
+ dv -l 3 -a 1 -I messy_scientific_data.csv
240
+
241
+ # Combine all options: skip lines, skip after header, no header, no inference, gzipped
242
+ dv -l 2 -a 1 -H -I complex_data.csv.gz
243
+
244
+ # Process compressed data from stdin with line skipping
245
+ zcat compressed_data.csv.gz | dv -f csv -l 2
246
+
247
+ # CSV with custom null values and no header
248
+ dv -H -u NA "N/A" "-" raw_data.csv
249
+
250
+ # Skip lines, specify null values, and disable type inference
251
+ dv -l 5 -u NA "" data_with_metadata.csv
252
+
253
+ # TSV file with problematic quotes in data fields
254
+ dv -q None data.tsv
255
+
256
+ # CSV with comment lines and custom null values
257
+ dv -c "#" -u NA "N/A" commented_data.csv
258
+ ```
259
+
154
260
  ## Keyboard Shortcuts
155
261
 
156
262
  ### App-Level Controls
@@ -161,7 +267,7 @@ When multiple files are opened:
161
267
  |-----|--------|
162
268
  | `Ctrl+O` | Open file in a new tab |
163
269
  | `Ctrl+W` | Close current tab |
164
- | `Ctrl+Shift+S` | Save all open tabs to Excel file |
270
+ | `Ctrl+A` | Save all open tabs to Excel file |
165
271
  | `>` or `b` | Move to next tab |
166
272
  | `<` | Move to previous tab |
167
273
  | `B` | Toggle tab bar visibility |
@@ -171,7 +277,7 @@ When multiple files are opened:
171
277
 
172
278
  | Key | Action |
173
279
  |-----|--------|
174
- | `Ctrl+H` | Toggle help panel |
280
+ | `F1` | Toggle help panel |
175
281
  | `k` | Cycle through themes |
176
282
 
177
283
  ---
@@ -189,6 +295,8 @@ When multiple files are opened:
189
295
  | `Home` / `End` | Jump to first/last column in current row |
190
296
  | `Ctrl + Home` / `Ctrl + End` | Jump to top/bottom in current page |
191
297
  | `PageDown` / `PageUp` | Scroll down/up one page |
298
+ | `Ctrl+F` | Page down |
299
+ | `Ctrl+B` | Page up |
192
300
 
193
301
  #### Viewing & Display
194
302
 
@@ -200,6 +308,7 @@ When multiple files are opened:
200
308
  | `S` | Show statistics for entire dataframe |
201
309
  | `K` | Cycle cursor type: cell → row → column → cell |
202
310
  | `~` | Toggle row labels |
311
+ | `_` (underscore) | Expand column to full width |
203
312
 
204
313
  #### Data Editing
205
314
 
@@ -211,9 +320,8 @@ When multiple files are opened:
211
320
  | `E` | Edit entire column with expression |
212
321
  | `a` | Add empty column after current |
213
322
  | `A` | Add column with name and value/expression |
323
+ | `@` | Add a link column from template expression |
214
324
  | `-` (minus) | Delete current column |
215
- | `_` (underscore) | Delete current column and all columns after |
216
- | `Ctrl+-` | Delete current column and all columns before |
217
325
  | `x` | Delete current row |
218
326
  | `X` | Delete current row and all rows below |
219
327
  | `Ctrl+X` | Delete current row and all rows above |
@@ -241,12 +349,19 @@ When multiple files are opened:
241
349
  | `v` | View only rows by selected rows and/or matches or cursor value |
242
350
  | `V` | View only rows by expression |
243
351
 
352
+ #### SQL Interface
353
+
354
+ | Key | Action |
355
+ |-----|--------|
356
+ | `l` | Simple SQL interface (select columns & WHERE clause) |
357
+ | `L` | Advanced SQL interface (full SQL queries) |
358
+
244
359
  #### Find & Replace
245
360
 
246
361
  | Key | Action |
247
362
  |-----|--------|
248
- | `f` | Find across all columns with cursor value |
249
- | `Ctrl+F` | Find across all columns with expression |
363
+ | `;` | Find across all columns with cursor value |
364
+ | `:` | Find across all columns with expression |
250
365
  | `r` | Find and replace in current column (interactive or replace all) |
251
366
  | `R` | Find and replace across all columns (interactive or replace all) |
252
367
 
@@ -274,7 +389,6 @@ When multiple files are opened:
274
389
  | `%` | Cast current column to float (Float64) |
275
390
  | `!` | Cast current column to boolean |
276
391
  | `$` | Cast current column to string |
277
- | `@` | Make URLs in current column clickable with Ctrl/Cmd + click|
278
392
 
279
393
  #### Data Management
280
394
 
@@ -322,8 +436,8 @@ The application provides multiple search modes for different use cases:
322
436
  **Find Operations** - Find by value/expression:
323
437
  - **`/` - Column Find**: Find cursor value within current column
324
438
  - **`?` - Column Expression Find**: Open dialog to search current column with expression
325
- - **`f` - Global Find**: Find cursor value across all columns
326
- - **`Ctrl+f` - Global Expression Find**: Open dialog to search all columns with expression
439
+ - **`;` - Global Find**: Find cursor value across all columns
440
+ - **`:` - Global Expression Find**: Open dialog to search all columns with expression
327
441
 
328
442
  **Selection & Filtering**:
329
443
  - **`'` - Toggle Row Selection**: Select/deselect current row (marks it for filtering)
@@ -696,12 +810,38 @@ Press `K` to cycle through selection modes:
696
810
  2. **Row mode**: Highlight entire row
697
811
  3. **Column mode**: Highlight entire column
698
812
 
699
- ### 18. URL Handling
813
+ ### 18. SQL Interface
814
+
815
+ The SQL interface provides two modes for querying your dataframe:
816
+
817
+ #### Simple SQL Interface (`l`)
818
+ Select specific columns and apply WHERE conditions without writing full SQL:
819
+ - Choose which columns to include in results
820
+ - Specify WHERE clause for filtering
821
+ - Ideal for quick filtering and column selection
700
822
 
701
- Press `@` to make URLs in the current column clickable:
702
- - **Ctrl/Cmd + click** on URLs to open them in your default browser
703
- - **Scans** all cells in the current column for URLs starting with `http://` or `https://`
704
- - **Applies** link styling to make them clickable and dataframe remains unchanged
823
+ #### Advanced SQL Interface (`L`)
824
+ Execute complete SQL queries for advanced data manipulation:
825
+ - Write full SQL queries with standard [SQL syntax](https://docs.pola.rs/api/python/stable/reference/sql/index.html)
826
+ - Support for JOINs, GROUP BY, aggregations, and more
827
+ - Access to all SQL capabilities for complex transformations
828
+ - Always use `self` as the table name
829
+
830
+ **Examples:**
831
+ ```sql
832
+ -- Filter and select specific rows and/or columns
833
+ SELECT name, age FROM self WHERE age > 30
834
+
835
+ -- Aggregate with GROUP BY
836
+ SELECT department, COUNT(*) as count, AVG(salary) as avg_salary
837
+ FROM self
838
+ GROUP BY department
839
+
840
+ -- Complex filtering with multiple conditions
841
+ SELECT *
842
+ FROM self
843
+ WHERE (age > 25 AND salary > 50000) OR department = 'Management'
844
+ ```
705
845
 
706
846
  ### 19. Clipboard Operations
707
847
 
@@ -712,6 +852,73 @@ Press `Ctrl+C` to copy:
712
852
  - Press `Ctrl+C` to copy column values
713
853
  - Press `Ctrl+R` to copy row values (delimited by tab)
714
854
 
855
+ ### 20. Link Column Creation
856
+
857
+ Press `@` to create a new column containing dynamically generated URLs using template expressions.
858
+
859
+ **Template Placeholders:**
860
+
861
+ The link template supports multiple placeholder types for maximum flexibility:
862
+
863
+ - **`$_`** - Current column (the column where cursor was when `@` was pressed)
864
+ - Example: `https://example.com/search/$_` - Uses values from the current column
865
+ - Useful for quick links based on the focused column
866
+
867
+ - **`$1`, `$2`, `$3`, etc.** - Column by 1-based position index
868
+ - Example: `https://example.com/product/$1/details/$2` - Uses 1st and 2nd columns
869
+ - Useful for structured templates spanning multiple columns
870
+ - Index corresponds to column display order (left-to-right)
871
+
872
+ - **`$name`** - Column by name (use actual column names)
873
+ - Example: `https://pubchem.ncbi.nlm.nih.gov/search?q=$product_id` - Uses `product_id` column
874
+ - Example: `https://example.com/$region/$city/data` - Uses `region` and `city` columns
875
+ - Useful for readable, self-documenting templates
876
+
877
+ **Features:**
878
+
879
+ - **Vectorized Expression**: All rows processed efficiently using Polars' vectorized operations
880
+ - **Type Casting**: Column values automatically converted to strings for URL construction
881
+ - **Multiple Placeholders**: Mix and match placeholders in a single template
882
+ - **URL Prefix**: Automatically prepends `https://` if URL doesn't start with `http://` or `https://`
883
+ - **PubChem Support**: Special shorthand - replace `PC` with full PubChem URL
884
+
885
+ **Examples:**
886
+
887
+ ```
888
+ Template: https://example.com/$_
889
+ Current column: product_id
890
+ Result: https://example.com/ABC123 (for each row's product_id value)
891
+
892
+ Template: https://database.org/view?id=$1&lang=$2
893
+ Column 1: item_code, Column 2: language
894
+ Result: https://database.org/view?id=X001&lang=en
895
+
896
+ Template: https://example.com/$username/profile
897
+ Column: username (must exist in dataframe)
898
+ Result: https://example.com/john_doe/profile
899
+
900
+ Template: https://example.com/$region/$city
901
+ Columns: region, city
902
+ Result: https://example.com/north/seattle
903
+
904
+ Template: PC/compound/$1
905
+ Column 1: pubchem_cid
906
+ Result: https://pubchem.ncbi.nlm.nih.gov/compound/12345
907
+ ```
908
+
909
+ **Error Handling:**
910
+
911
+ - **Invalid column index**: `$5` when only 3 columns exist → Error message showing valid range
912
+ - **Non-existent column name**: `$invalid_column` → Error message with available columns
913
+ - **No placeholders**: Template treated as constant → All rows get identical URL
914
+
915
+ **Tips:**
916
+
917
+ - Use descriptive column names for `$name` placeholders to make templates self-documenting
918
+ - Test with a small dataset first to verify template correctness
919
+ - Use full undo (`u`) if template produces unexpected URLs
920
+ - For complex multi-column URLs, use column names (`$name`) for clarity over positions (`$1`)
921
+
715
922
  ## Examples
716
923
 
717
924
  ### Single File Examples
@@ -722,6 +929,30 @@ dv pokemon.csv
722
929
 
723
930
  # Chain with other command and specify input file format
724
931
  cut -d',' -f1,2,3 pokemon.csv | dv -f csv
932
+
933
+ # Work with gzipped files
934
+ dv large_dataset.csv.gz
935
+
936
+ # CSV file without header row
937
+ dv -H raw_data.csv
938
+
939
+ # Skip type inference for faster loading
940
+ dv -I huge_file.csv
941
+
942
+ # Skip first 5 lines (comments, metadata)
943
+ dv -L 5 data_with_metadata.csv
944
+
945
+ # Skip 1 row after header (units row)
946
+ dv -K 1 data_with_units.csv
947
+
948
+ # Complex CSV with comments and units row
949
+ dv -L 3 -K 1 -I messy_scientific_data.csv
950
+
951
+ # Combine all options: skip lines, skip after header, no header, no inference, gzipped
952
+ dv -L 2 -K 1 -H -I complex_data.csv.gz
953
+
954
+ # Process compressed data from stdin with line skipping
955
+ zcat compressed_data.csv.gz | dv -f csv -L 2
725
956
  ```
726
957
 
727
958
  ### Multi-File/Tab Examples
@@ -730,8 +961,8 @@ cut -d',' -f1,2,3 pokemon.csv | dv -f csv
730
961
  # Open multiple sheets as tabs in a single Excel
731
962
  dv sales.xlsx
732
963
 
733
- # Open multiple files as tabs
734
- dv pokemon.csv titanic.csv
964
+ # Open multiple files as tabs (including gzipped)
965
+ dv pokemon.csv titanic.csv large_data.csv.gz
735
966
 
736
967
  # Start with one file, then open others using Ctrl+O
737
968
  dv initial_data.csv