dataframe-textual 2.32.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.
Files changed (19) hide show
  1. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/PKG-INFO +46 -46
  2. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/README.md +43 -43
  3. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/pyproject.toml +3 -3
  4. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/__main__.py +67 -20
  5. dataframe_textual-2.35.0/src/dataframe_textual/common.py +961 -0
  6. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_table.py +241 -97
  7. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_viewer.py +22 -21
  8. dataframe_textual-2.32.0/src/dataframe_textual/file_picker.py → dataframe_textual-2.35.0/src/dataframe_textual/file_picker_screen.py +6 -6
  9. dataframe_textual-2.35.0/src/dataframe_textual/loading_screen.py +50 -0
  10. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/table_screen.py +25 -23
  11. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/yes_no_screen.py +1 -1
  12. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/uv.lock +16 -16
  13. dataframe_textual-2.32.0/src/dataframe_textual/common.py → dataframe_textual-2.35.0/xbk/common.py_w_compute_error +15 -13
  14. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/.gitignore +0 -0
  15. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/LICENSE +0 -0
  16. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/main.py +0 -0
  17. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/__init__.py +0 -0
  18. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/data_frame_help_panel.py +0 -0
  19. {dataframe_textual-2.32.0 → dataframe_textual-2.35.0}/src/dataframe_textual/theme_screen.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataframe-textual
3
- Version: 2.32.0
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
@@ -29,9 +29,9 @@ Classifier: Topic :: Utilities
29
29
  Classifier: Typing :: Typed
30
30
  Requires-Python: >=3.11
31
31
  Requires-Dist: fastexcel>=0.16.0
32
- Requires-Dist: polars>=1.34.0
32
+ Requires-Dist: polars>1.39.0
33
33
  Requires-Dist: textual[syntax]>=8.0.2
34
- Requires-Dist: vortex-data>=0.59.4
34
+ Requires-Dist: vortex-data>=0.60.0
35
35
  Requires-Dist: xlsxwriter>=3.2.9
36
36
  Provides-Extra: dev
37
37
  Requires-Dist: textual-dev>=1.8.0; extra == 'dev'
@@ -46,7 +46,7 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet]
46
46
  ## Features
47
47
 
48
48
  ### Data Viewing
49
- - 🚀 **Fast Loading** - Powered by Polars for efficient data handling
49
+ - 🚀 **Fast Loading** - Powered by Polars for efficient batch data handling
50
50
  - 🎨 **Rich Terminal UI** - Beautiful, color-coded columns with various data types (e.g., integer, float, string)
51
51
  - ⌨️ **Comprehensive Keyboard Navigation** - Intuitive controls
52
52
  - 📊 **Flexible Input** - Read from files and/or stdin (pipes/redirects)
@@ -78,26 +78,15 @@ pip install dataframe-textual
78
78
 
79
79
  This installs an executable `dv`.
80
80
 
81
- Then run:
82
- ```bash
83
- dv <file>
84
- ```
85
81
 
86
82
  ### Using [uv](https://docs.astral.sh/uv/)
87
83
 
88
84
  ```bash
89
85
  # Install as a tool
90
- uv install dataframe-textual
86
+ uv tool install dataframe-textual
91
87
 
92
88
  # Quick run using uvx without installation
93
89
  uvx https://github.com/need47/dataframe-textual.git <csvfile>
94
-
95
- # Clone or download the project
96
- cd dataframe-textual
97
- uv sync
98
-
99
- # Run directly with uv
100
- uv run dv <file>
101
90
  ```
102
91
 
103
92
  ### Development installation
@@ -107,10 +96,7 @@ uv run dv <file>
107
96
  git clone https://github.com/need47/dataframe-textual.git
108
97
  cd dataframe-textual
109
98
 
110
- # Install from local source
111
- pip install -e .
112
-
113
- # With development dependencies
99
+ # Install from local source with development dependencies
114
100
  pip install -e ".[dev]"
115
101
  ```
116
102
 
@@ -122,12 +108,6 @@ pip install -e ".[dev]"
122
108
  # After pip install dataframe-textual
123
109
  dv pokemon.csv
124
110
 
125
- # Or run from module
126
- python -m dataframe-textual pokemon.csv
127
-
128
- # Or with uv
129
- uv run python main.py pokemon.csv
130
-
131
111
  # Read from stdin (defaults to TSV)
132
112
  cat data.tsv | dv
133
113
  dv < data.tsv
@@ -152,11 +132,19 @@ dv file.xlsx
152
132
  dv data1.tsv < data2.tsv
153
133
  ```
154
134
 
135
+ ### Multi-File Usage - Single Tab
136
+
137
+ ```bash
138
+
139
+ # Read all parquet files (must be of same format and same structure) into one single table
140
+ dv *.parquet --all-in-one
141
+ ```
142
+
155
143
  When multiple files are opened:
156
144
  - Each file appears as a separate tab. An Excel file may contain multiple tabs.
157
145
  - Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
158
146
  - Save current tab to file with `Ctrl+T`
159
- - Save all tabs to file with `Ctrl+A`
147
+ - Save all tabs to file with `Ctrl+S`
160
148
  - Duplicate the current tab with `Ctrl+D`
161
149
  - Open additional files with `Ctrl+O`
162
150
  - Each file maintains its own state (edits, sort order, selections, history, etc.) and allow undo/redo.
@@ -164,10 +152,11 @@ When multiple files are opened:
164
152
  ## Command Line Options
165
153
 
166
154
  ```
167
- usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]]
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]
168
157
  [files ...]
169
158
 
170
- Interactive terminal based viewer/editor for tabular data (e.g., CSV/Excel).
159
+ TUI viewer/editor for tabular data (e.g., CSV/Excel).
171
160
 
172
161
  positional arguments:
173
162
  files Files to view (or read from stdin)
@@ -176,17 +165,19 @@ options:
176
165
  -h, --help show this help message and exit
177
166
  -V, --version show program's version number and exit
178
167
  -d, --delimiter DELIMITER
179
- Specify the delimiter of the input files (must be a single character, e.g., `,` or `|`)
168
+ Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`)
180
169
  -f, --fields [FIELDS ...]
181
170
  When used without values, list available fields. Otherwise, read only specified fields.
182
171
  -H, --header [HEADER ...]
183
- Specify header info. when reading CSV/TSV. If used without values, assumes no header. Otherwise, use provided values as column names (e.g., `-H col1 col2 col3`).
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`).
173
+ -L, --infer_schema_length [N]
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).
184
175
  -I, --no-inference Do not infer data types when reading CSV/TSV
185
176
  -T, --truncate-ragged-lines
186
177
  Truncate ragged lines when reading CSV/TSV
187
178
  -E, --ignore-errors Ignore errors when reading CSV/TSV
188
179
  -C, --comment-prefix [PREFIX]
189
- Comment lines starting with `PREFIX` are skipped when reading CSV/TSV
180
+ Skip comment lines starting with `PREFIX` when reading CSV/TSV
190
181
  -Q, --quote-char [C] Use `C` as quote character for reading CSV/TSV. When used without value, disables special handling of quote characters.
191
182
  -K, --skip-lines N Skip first N lines when reading CSV/TSV
192
183
  -A, --skip-rows-after-header N
@@ -194,9 +185,11 @@ options:
194
185
  -M, --n-rows N Read maximum rows
195
186
  -N, --null NULL [NULL ...]
196
187
  Values to interpret as null values when reading CSV/TSV
197
- --sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
198
188
  --theme [THEME] Set the theme for the application. If used without value, show available themes.
199
- --all-in-one, --aio Read all files (must be of the same structure) into a single table.
189
+ --all-in-one, --aio, --one
190
+ Read all files (must be of same format and same structure) into one single table.
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).
200
193
  ```
201
194
 
202
195
  ### CLI Examples
@@ -235,7 +228,7 @@ dv large_data.csv -I
235
228
  # Ignore parsing errors in malformed CSV
236
229
  dv data_with_errors.csv -E
237
230
 
238
- # Treat specific values as null/missing (e.g., 'NA', 'N/A', '-')
231
+ # Treat specific values as null/missing (e.g., 'NA', 'N/A')
239
232
  dv data.csv -N NA N/A
240
233
 
241
234
  # Use different quote character (e.g., single quote for CSV)
@@ -253,11 +246,14 @@ dv data.csv -f
253
246
  # Read only specific columns: 'name', 'age', first column, and last column
254
247
  dv data.csv -f name age 1 -1
255
248
 
249
+ # Read all files (must be of same format and same structure) into one single table
250
+ dv data-1.csv data-2.csv --all-in-one
251
+
256
252
  # Filter data using SQL query (use 'self' as the table name)
257
253
  dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
258
254
 
259
- # Read all files (must be of the same structure) into a single table
260
- dv data-1.csv data-2.csv --all-in-one
255
+ # Convert to other format
256
+ dv data.csv -o data.parquet
261
257
  ```
262
258
 
263
259
  ## Keyboard Shortcuts
@@ -268,12 +264,13 @@ dv data-1.csv data-2.csv --all-in-one
268
264
 
269
265
  | Key | Action |
270
266
  | -------------- | ------------------------------------------------------------- |
271
- | `>` | Move current tab right (wrap to first) |
272
- | `<` | Move current tab left (wrap to last) |
273
- | `b` | Cycle through tabs |
274
- | `B` | Toggle tab bar visibility |
275
267
  | `q` | Close current tab (prompts to save unsaved changes) |
276
268
  | `Q` | Close all tabs and quit app (prompts to save unsaved changes) |
269
+ | `space` | Toggle tab bar visibility |
270
+ | `b` | Next tab |
271
+ | `B` | Previous tab |
272
+ | `>` | Move current tab right (wrap to first) |
273
+ | `<` | Move current tab left (wrap to last) |
277
274
  | `Ctrl+Q` | Force to quit app (regardless of unsaved changes) |
278
275
  | `Ctrl+V` | Save current view to file |
279
276
  | `Ctrl+T` | Save current tab to file |
@@ -286,11 +283,11 @@ dv data-1.csv data-2.csv --all-in-one
286
283
 
287
284
  #### View & Settings
288
285
 
289
- | Key | Action |
290
- | ------------------------ | ------------------------------------------ |
291
- | `F1` | Toggle help panel |
292
- | `k` | Select theme |
293
- | `Ctrl+P` -> `Screenshot` | Capture terminal view as a SVG image |
286
+ | Key | Action |
287
+ | ------------------------ | ------------------------------------ |
288
+ | `F1` | Toggle help panel |
289
+ | `k` | Select theme |
290
+ | `Ctrl+P` -> `Screenshot` | Capture terminal view as a SVG image |
294
291
 
295
292
  ---
296
293
 
@@ -629,6 +626,9 @@ Press `F` to see value distributions of the current column. The modal shows:
629
626
  - Press `[` and `]` to sort by any column (value, count, or percentage)
630
627
  - Press `v` to **view** all rows containing the selected value
631
628
  - Press `"` to **filter** all rows containing the selected value to a new tab
629
+ - Press `,` to toggle thousand separator
630
+ - Press `g` to scroll to top
631
+ - Press `G` to scroll to bottom
632
632
  - Press `Ctrl+S` to save the frequency table to file
633
633
  - Press `q` or `Escape` to close the frequency table
634
634
 
@@ -7,7 +7,7 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet]
7
7
  ## Features
8
8
 
9
9
  ### Data Viewing
10
- - 🚀 **Fast Loading** - Powered by Polars for efficient data handling
10
+ - 🚀 **Fast Loading** - Powered by Polars for efficient batch data handling
11
11
  - 🎨 **Rich Terminal UI** - Beautiful, color-coded columns with various data types (e.g., integer, float, string)
12
12
  - ⌨️ **Comprehensive Keyboard Navigation** - Intuitive controls
13
13
  - 📊 **Flexible Input** - Read from files and/or stdin (pipes/redirects)
@@ -39,26 +39,15 @@ pip install dataframe-textual
39
39
 
40
40
  This installs an executable `dv`.
41
41
 
42
- Then run:
43
- ```bash
44
- dv <file>
45
- ```
46
42
 
47
43
  ### Using [uv](https://docs.astral.sh/uv/)
48
44
 
49
45
  ```bash
50
46
  # Install as a tool
51
- uv install dataframe-textual
47
+ uv tool install dataframe-textual
52
48
 
53
49
  # Quick run using uvx without installation
54
50
  uvx https://github.com/need47/dataframe-textual.git <csvfile>
55
-
56
- # Clone or download the project
57
- cd dataframe-textual
58
- uv sync
59
-
60
- # Run directly with uv
61
- uv run dv <file>
62
51
  ```
63
52
 
64
53
  ### Development installation
@@ -68,10 +57,7 @@ uv run dv <file>
68
57
  git clone https://github.com/need47/dataframe-textual.git
69
58
  cd dataframe-textual
70
59
 
71
- # Install from local source
72
- pip install -e .
73
-
74
- # With development dependencies
60
+ # Install from local source with development dependencies
75
61
  pip install -e ".[dev]"
76
62
  ```
77
63
 
@@ -83,12 +69,6 @@ pip install -e ".[dev]"
83
69
  # After pip install dataframe-textual
84
70
  dv pokemon.csv
85
71
 
86
- # Or run from module
87
- python -m dataframe-textual pokemon.csv
88
-
89
- # Or with uv
90
- uv run python main.py pokemon.csv
91
-
92
72
  # Read from stdin (defaults to TSV)
93
73
  cat data.tsv | dv
94
74
  dv < data.tsv
@@ -113,11 +93,19 @@ dv file.xlsx
113
93
  dv data1.tsv < data2.tsv
114
94
  ```
115
95
 
96
+ ### Multi-File Usage - Single Tab
97
+
98
+ ```bash
99
+
100
+ # Read all parquet files (must be of same format and same structure) into one single table
101
+ dv *.parquet --all-in-one
102
+ ```
103
+
116
104
  When multiple files are opened:
117
105
  - Each file appears as a separate tab. An Excel file may contain multiple tabs.
118
106
  - Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
119
107
  - Save current tab to file with `Ctrl+T`
120
- - Save all tabs to file with `Ctrl+A`
108
+ - Save all tabs to file with `Ctrl+S`
121
109
  - Duplicate the current tab with `Ctrl+D`
122
110
  - Open additional files with `Ctrl+O`
123
111
  - Each file maintains its own state (edits, sort order, selections, history, etc.) and allow undo/redo.
@@ -125,10 +113,11 @@ When multiple files are opened:
125
113
  ## Command Line Options
126
114
 
127
115
  ```
128
- usage: dv [-h] [-V] [-d DELIMITER] [-f [FIELDS ...]] [-H [HEADER ...]] [-I] [-T] [-E] [-C [PREFIX]] [-Q [C]] [-K N] [-A N] [-M N] [-N NULL [NULL ...]] [--theme [THEME]]
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]
129
118
  [files ...]
130
119
 
131
- Interactive terminal based viewer/editor for tabular data (e.g., CSV/Excel).
120
+ TUI viewer/editor for tabular data (e.g., CSV/Excel).
132
121
 
133
122
  positional arguments:
134
123
  files Files to view (or read from stdin)
@@ -137,17 +126,19 @@ options:
137
126
  -h, --help show this help message and exit
138
127
  -V, --version show program's version number and exit
139
128
  -d, --delimiter DELIMITER
140
- Specify the delimiter of the input files (must be a single character, e.g., `,` or `|`)
129
+ Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`)
141
130
  -f, --fields [FIELDS ...]
142
131
  When used without values, list available fields. Otherwise, read only specified fields.
143
132
  -H, --header [HEADER ...]
144
- Specify header info. when reading CSV/TSV. If used without values, assumes no header. Otherwise, use provided values as column names (e.g., `-H col1 col2 col3`).
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`).
134
+ -L, --infer_schema_length [N]
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).
145
136
  -I, --no-inference Do not infer data types when reading CSV/TSV
146
137
  -T, --truncate-ragged-lines
147
138
  Truncate ragged lines when reading CSV/TSV
148
139
  -E, --ignore-errors Ignore errors when reading CSV/TSV
149
140
  -C, --comment-prefix [PREFIX]
150
- Comment lines starting with `PREFIX` are skipped when reading CSV/TSV
141
+ Skip comment lines starting with `PREFIX` when reading CSV/TSV
151
142
  -Q, --quote-char [C] Use `C` as quote character for reading CSV/TSV. When used without value, disables special handling of quote characters.
152
143
  -K, --skip-lines N Skip first N lines when reading CSV/TSV
153
144
  -A, --skip-rows-after-header N
@@ -155,9 +146,11 @@ options:
155
146
  -M, --n-rows N Read maximum rows
156
147
  -N, --null NULL [NULL ...]
157
148
  Values to interpret as null values when reading CSV/TSV
158
- --sql SQL Specify a SQL query to execute on the input file (e.g., to select and filter data)
159
149
  --theme [THEME] Set the theme for the application. If used without value, show available themes.
160
- --all-in-one, --aio Read all files (must be of the same structure) into a single table.
150
+ --all-in-one, --aio, --one
151
+ Read all files (must be of same format and same structure) into one single table.
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).
161
154
  ```
162
155
 
163
156
  ### CLI Examples
@@ -196,7 +189,7 @@ dv large_data.csv -I
196
189
  # Ignore parsing errors in malformed CSV
197
190
  dv data_with_errors.csv -E
198
191
 
199
- # Treat specific values as null/missing (e.g., 'NA', 'N/A', '-')
192
+ # Treat specific values as null/missing (e.g., 'NA', 'N/A')
200
193
  dv data.csv -N NA N/A
201
194
 
202
195
  # Use different quote character (e.g., single quote for CSV)
@@ -214,11 +207,14 @@ dv data.csv -f
214
207
  # Read only specific columns: 'name', 'age', first column, and last column
215
208
  dv data.csv -f name age 1 -1
216
209
 
210
+ # Read all files (must be of same format and same structure) into one single table
211
+ dv data-1.csv data-2.csv --all-in-one
212
+
217
213
  # Filter data using SQL query (use 'self' as the table name)
218
214
  dv data.csv --sql 'SELECT * FROM self WHERE age > 30'
219
215
 
220
- # Read all files (must be of the same structure) into a single table
221
- dv data-1.csv data-2.csv --all-in-one
216
+ # Convert to other format
217
+ dv data.csv -o data.parquet
222
218
  ```
223
219
 
224
220
  ## Keyboard Shortcuts
@@ -229,12 +225,13 @@ dv data-1.csv data-2.csv --all-in-one
229
225
 
230
226
  | Key | Action |
231
227
  | -------------- | ------------------------------------------------------------- |
232
- | `>` | Move current tab right (wrap to first) |
233
- | `<` | Move current tab left (wrap to last) |
234
- | `b` | Cycle through tabs |
235
- | `B` | Toggle tab bar visibility |
236
228
  | `q` | Close current tab (prompts to save unsaved changes) |
237
229
  | `Q` | Close all tabs and quit app (prompts to save unsaved changes) |
230
+ | `space` | Toggle tab bar visibility |
231
+ | `b` | Next tab |
232
+ | `B` | Previous tab |
233
+ | `>` | Move current tab right (wrap to first) |
234
+ | `<` | Move current tab left (wrap to last) |
238
235
  | `Ctrl+Q` | Force to quit app (regardless of unsaved changes) |
239
236
  | `Ctrl+V` | Save current view to file |
240
237
  | `Ctrl+T` | Save current tab to file |
@@ -247,11 +244,11 @@ dv data-1.csv data-2.csv --all-in-one
247
244
 
248
245
  #### View & Settings
249
246
 
250
- | Key | Action |
251
- | ------------------------ | ------------------------------------------ |
252
- | `F1` | Toggle help panel |
253
- | `k` | Select theme |
254
- | `Ctrl+P` -> `Screenshot` | Capture terminal view as a SVG image |
247
+ | Key | Action |
248
+ | ------------------------ | ------------------------------------ |
249
+ | `F1` | Toggle help panel |
250
+ | `k` | Select theme |
251
+ | `Ctrl+P` -> `Screenshot` | Capture terminal view as a SVG image |
255
252
 
256
253
  ---
257
254
 
@@ -590,6 +587,9 @@ Press `F` to see value distributions of the current column. The modal shows:
590
587
  - Press `[` and `]` to sort by any column (value, count, or percentage)
591
588
  - Press `v` to **view** all rows containing the selected value
592
589
  - Press `"` to **filter** all rows containing the selected value to a new tab
590
+ - Press `,` to toggle thousand separator
591
+ - Press `g` to scroll to top
592
+ - Press `G` to scroll to bottom
593
593
  - Press `Ctrl+S` to save the frequency table to file
594
594
  - Press `q` or `Escape` to close the frequency table
595
595
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dataframe-textual"
7
- version = "2.32.0"
7
+ version = "2.35.0"
8
8
  description = "Interactive terminal viewer/editor for tabular data"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -33,11 +33,11 @@ classifiers = [
33
33
  "Typing :: Typed",
34
34
  ]
35
35
  dependencies = [
36
- "polars>=1.34.0",
36
+ "polars>1.39.0",
37
37
  "fastexcel>=0.16.0",
38
38
  "xlsxwriter>=3.2.9",
39
39
  "textual[syntax]>=8.0.2",
40
- "vortex-data>=0.59.4",
40
+ "vortex-data>=0.60.0",
41
41
  ]
42
42
 
43
43
  [project.urls]
@@ -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 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
 
@@ -49,11 +49,11 @@ def cli() -> argparse.Namespace:
49
49
  """
50
50
  parser = argparse.ArgumentParser(
51
51
  prog="dv",
52
- description="Interactive terminal based viewer/editor for tabular data (e.g., CSV/Excel).",
52
+ description="TUI viewer/editor for tabular data (e.g., CSV/Excel).",
53
53
  formatter_class=argparse.RawDescriptionHelpFormatter,
54
54
  epilog="Examples:\n"
55
55
  " %(prog)s data.csv\n"
56
- " %(prog)s file1.csv file2.csv file3.csv\n"
56
+ " %(prog)s file1.csv.gz file2.tsv file3.csv\n"
57
57
  " %(prog)s data.xlsx (opens each sheet in separate tab)\n"
58
58
  " cat data.txt | %(prog)s -d ';'\n",
59
59
  )
@@ -67,7 +67,7 @@ def cli() -> argparse.Namespace:
67
67
  parser.add_argument(
68
68
  "-d",
69
69
  "--delimiter",
70
- help="Specify the delimiter of the input files (must be a single character, e.g., `,` or `|`)",
70
+ help="Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`)",
71
71
  )
72
72
  parser.add_argument(
73
73
  "-f",
@@ -83,7 +83,17 @@ def cli() -> argparse.Namespace:
83
83
  nargs="*",
84
84
  action=ConstWithMultiArgs,
85
85
  const=False,
86
- help="Specify header info. when reading CSV/TSV. If used without values, assumes no header. Otherwise, use provided values as column names (e.g., `-H col1 col2 col3`).",
86
+ help="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`).",
87
+ )
88
+ parser.add_argument(
89
+ "-L",
90
+ "--infer_schema_length",
91
+ nargs="?",
92
+ metavar="N",
93
+ type=int,
94
+ default=100,
95
+ const=None,
96
+ help="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).",
87
97
  )
88
98
  parser.add_argument(
89
99
  "-I", "--no-inference", action="store_true", help="Do not infer data types when reading CSV/TSV"
@@ -121,11 +131,14 @@ def cli() -> argparse.Namespace:
121
131
  help="Skip N rows after header when reading CSV/TSV",
122
132
  )
123
133
  parser.add_argument("-M", "--n-rows", metavar="N", type=int, help="Read maximum rows")
124
- parser.add_argument("-N", "--null", nargs="+", help="Values to interpret as null values when reading CSV/TSV")
125
-
126
134
  parser.add_argument(
127
- "--sql", help="Specify a SQL query to execute on the input file (e.g., to select and filter data)"
135
+ "-N",
136
+ "--null",
137
+ nargs="+",
138
+ default=["IsNULL", "NULL"],
139
+ help="Values to interpret as null values when reading CSV/TSV",
128
140
  )
141
+
129
142
  parser.add_argument(
130
143
  "--theme",
131
144
  nargs="?",
@@ -137,8 +150,19 @@ def cli() -> argparse.Namespace:
137
150
  parser.add_argument(
138
151
  "--all-in-one",
139
152
  "--aio",
153
+ "--one",
140
154
  action="store_true",
141
- help="Read all files (must be of the same structure) into a single table.",
155
+ help="Read all files (must be of same format and same structure) into one single table.",
156
+ )
157
+
158
+ parser.add_argument(
159
+ "--sql", help="Specify a SQL query to execute on the input file (e.g., to select and filter data)"
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).",
142
166
  )
143
167
 
144
168
  args = parser.parse_args()
@@ -162,14 +186,24 @@ def cli() -> argparse.Namespace:
162
186
  args.files = []
163
187
 
164
188
  # Check if reading from stdin (pipe or redirect)
165
- if not sys.stdin.isatty():
189
+ if not sys.stdin.isatty() and "-" not in args.files:
166
190
  args.files.append("-")
167
- else:
168
- # Validate all files exist
169
- for filename in args.files:
170
- if not Path(filename).exists():
171
- print(f"File not found: {filename}", file=sys.stderr)
172
- sys.exit(1)
191
+
192
+ # Validate all files
193
+ for filename in args.files:
194
+ if filename == "-":
195
+ continue # stdin will be handled separately
196
+
197
+ filepath = Path(filename)
198
+ if not filepath.exists():
199
+ print(f"File not found: `{filename}`", file=sys.stderr)
200
+ sys.exit(1)
201
+ elif not filepath.is_file():
202
+ print(f"Not a file: `{filename}`", file=sys.stderr)
203
+ sys.exit(1)
204
+ elif filepath.stat().st_size == 0:
205
+ print(f"File is empty: `{filename}`", file=sys.stderr)
206
+ sys.exit(1)
173
207
 
174
208
  if not args.files:
175
209
  parser.print_help()
@@ -181,11 +215,20 @@ def cli() -> argparse.Namespace:
181
215
  def main() -> None:
182
216
  args = cli()
183
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
+
184
226
  sources = load_dataframe(
185
227
  args.files,
186
228
  delimiter=args.delimiter,
187
229
  header=args.header,
188
230
  infer_schema=not args.no_inference,
231
+ infer_schema_length=args.infer_schema_length,
189
232
  comment_prefix=args.comment_prefix,
190
233
  quote_char=args.quote_char,
191
234
  skip_lines=args.skip_lines,
@@ -201,7 +244,7 @@ def main() -> None:
201
244
  # List available fields and exit
202
245
  if args.fields == "list":
203
246
  for source in sources:
204
- for idx, field in enumerate(source.frame.columns):
247
+ for idx, field in enumerate(source.lf.collect_schema().names()):
205
248
  print(idx + 1, field, sep="\t")
206
249
  break # Only list fields for the first source
207
250
 
@@ -209,16 +252,20 @@ def main() -> None:
209
252
 
210
253
  if args.sql:
211
254
  for source in sources:
212
- ctx = pl.SQLContext(frames={"self": source.frame})
255
+ ctx = pl.SQLContext(frames={"self": source.lf})
213
256
  try:
214
- source.frame = ctx.execute(args.sql)
257
+ source.lf = ctx.execute(args.sql)
215
258
  except pl.exceptions.SQLInterfaceError as e:
216
259
  print(f"SQL error: {e}", file=sys.stderr)
217
260
  sys.exit(1)
218
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
+
219
266
  # Run the DataFrame Viewer application
220
267
  app = DataFrameViewer(*sources, theme=args.theme)
221
- app.run()
268
+ handle_compute_error(app.run())
222
269
 
223
270
 
224
271
  if __name__ == "__main__":