dataframe-textual 2.36.0__tar.gz → 2.37.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.36.0 → dataframe_textual-2.37.0}/PKG-INFO +21 -30
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/README.md +20 -29
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/pyproject.toml +1 -1
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/__main__.py +41 -14
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/common.py +28 -10
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/uv.lock +1 -1
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/.gitignore +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/LICENSE +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/main.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/__init__.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_help_panel.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_table.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_viewer.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/file_picker_screen.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/loading_screen.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/table_screen.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/theme_screen.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/yes_no_screen.py +0 -0
- {dataframe_textual-2.36.0 → dataframe_textual-2.37.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.37.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
|
|
@@ -39,7 +39,7 @@ Description-Content-Type: text/markdown
|
|
|
39
39
|
|
|
40
40
|
# DataFrame Textual
|
|
41
41
|
|
|
42
|
-
A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet](https://parquet.apache.org/)/[Vortex](https://vortex.dev/)/JSON/NDJSON built with Python, [Polars](https://pola.rs/), and [Textual](https://textual.textualize.io/). Inspired by [VisiData](https://www.visidata.org/), this tool provides smooth keyboard navigation, data manipulation, and a clean interface for exploring tabular data directly in terminal with multi-tab support for multiple files!
|
|
42
|
+
A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet](https://parquet.apache.org/)/[Vortex](https://vortex.dev/)/JSON/[NDJSON](https://jsonlines.org/) built with Python, [Polars](https://pola.rs/), and [Textual](https://textual.textualize.io/). Inspired by [VisiData](https://www.visidata.org/), this tool provides smooth keyboard navigation, data manipulation, and a clean interface for exploring tabular data directly in terminal with multi-tab support for multiple files!
|
|
43
43
|
|
|
44
44
|

|
|
45
45
|
|
|
@@ -107,16 +107,6 @@ pip install -e ".[dev]"
|
|
|
107
107
|
```bash
|
|
108
108
|
# After pip install dataframe-textual
|
|
109
109
|
dv pokemon.csv
|
|
110
|
-
|
|
111
|
-
# Read from stdin (defaults to TSV)
|
|
112
|
-
cat data.tsv | dv
|
|
113
|
-
dv < data.tsv
|
|
114
|
-
|
|
115
|
-
# Specify delimiter
|
|
116
|
-
dv data.txt -d '|'
|
|
117
|
-
|
|
118
|
-
# Gzipped files are supported
|
|
119
|
-
dv data.csv.gz
|
|
120
110
|
```
|
|
121
111
|
|
|
122
112
|
### Multi-File Usage - Multiple Tabs
|
|
@@ -140,20 +130,11 @@ dv data1.tsv < data2.tsv
|
|
|
140
130
|
dv *.parquet --all-in-one
|
|
141
131
|
```
|
|
142
132
|
|
|
143
|
-
When multiple files are opened:
|
|
144
|
-
- Each file appears as a separate tab. An Excel file may contain multiple tabs.
|
|
145
|
-
- Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
|
|
146
|
-
- Save current tab to file with `Ctrl+T`
|
|
147
|
-
- Save all tabs to file with `Ctrl+S`
|
|
148
|
-
- Duplicate the current tab with `Ctrl+D`
|
|
149
|
-
- Open additional files with `Ctrl+O`
|
|
150
|
-
- Each file maintains its own state (edits, sort order, selections, history, etc.) and allow undo/redo.
|
|
151
|
-
|
|
152
133
|
## Command Line Options
|
|
153
134
|
|
|
154
135
|
```
|
|
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]]
|
|
156
|
-
[--sql SQL] [-o OUTPUT]
|
|
136
|
+
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]]
|
|
137
|
+
[--all-in-one] [--sql SQL] [-o OUTPUT]
|
|
157
138
|
[files ...]
|
|
158
139
|
|
|
159
140
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -165,8 +146,11 @@ options:
|
|
|
165
146
|
-h, --help show this help message and exit
|
|
166
147
|
-V, --version show program's version number and exit
|
|
167
148
|
-d, --delimiter DELIMITER
|
|
168
|
-
Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`)
|
|
169
|
-
|
|
149
|
+
Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`). By default, the delimiter is inferred from the file extension. If reading from stdin, the
|
|
150
|
+
delimiter must be specified unless it is tab delimited.
|
|
151
|
+
-f, --format FORMAT Specify the format of the input files (e.g., `csv` or `excel`). By default, the format is inferred from the file extension. If reading from stdin, the format must be specified
|
|
152
|
+
unless it is tab delimited.
|
|
153
|
+
-F, --fields [FIELDS ...]
|
|
170
154
|
When used without values, list available fields. Otherwise, read only specified fields.
|
|
171
155
|
-H, --header [HEADER ...]
|
|
172
156
|
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`).
|
|
@@ -198,11 +182,18 @@ options:
|
|
|
198
182
|
# Open a file
|
|
199
183
|
dv data.csv
|
|
200
184
|
|
|
201
|
-
#
|
|
185
|
+
# Gzipped files are supported
|
|
202
186
|
dv data.csv.gz
|
|
203
187
|
|
|
204
|
-
# Read from stdin
|
|
205
|
-
|
|
188
|
+
# Read from stdin (defaults to TSV)
|
|
189
|
+
cat data.tsv | dv
|
|
190
|
+
dv < data.tsv
|
|
191
|
+
|
|
192
|
+
# Specify delimiter
|
|
193
|
+
dv data.txt -d '|'
|
|
194
|
+
|
|
195
|
+
# Specify format
|
|
196
|
+
dv data.json -f ndjson
|
|
206
197
|
|
|
207
198
|
# View headless CSV file
|
|
208
199
|
dv data_no_header.csv -H
|
|
@@ -241,10 +232,10 @@ dv data.tsv -Q
|
|
|
241
232
|
dv data.csv --theme monokai
|
|
242
233
|
|
|
243
234
|
# Show column headers
|
|
244
|
-
dv data.csv -
|
|
235
|
+
dv data.csv -F
|
|
245
236
|
|
|
246
237
|
# Read only specific columns: 'name', 'age', first column, and last column
|
|
247
|
-
dv data.csv -
|
|
238
|
+
dv data.csv -F name age 1 -1
|
|
248
239
|
|
|
249
240
|
# Read all files (must be of same format and same structure) into one single table
|
|
250
241
|
dv data-1.csv data-2.csv --all-in-one
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DataFrame Textual
|
|
2
2
|
|
|
3
|
-
A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet](https://parquet.apache.org/)/[Vortex](https://vortex.dev/)/JSON/NDJSON built with Python, [Polars](https://pola.rs/), and [Textual](https://textual.textualize.io/). Inspired by [VisiData](https://www.visidata.org/), this tool provides smooth keyboard navigation, data manipulation, and a clean interface for exploring tabular data directly in terminal with multi-tab support for multiple files!
|
|
3
|
+
A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet](https://parquet.apache.org/)/[Vortex](https://vortex.dev/)/JSON/[NDJSON](https://jsonlines.org/) built with Python, [Polars](https://pola.rs/), and [Textual](https://textual.textualize.io/). Inspired by [VisiData](https://www.visidata.org/), this tool provides smooth keyboard navigation, data manipulation, and a clean interface for exploring tabular data directly in terminal with multi-tab support for multiple files!
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -68,16 +68,6 @@ pip install -e ".[dev]"
|
|
|
68
68
|
```bash
|
|
69
69
|
# After pip install dataframe-textual
|
|
70
70
|
dv pokemon.csv
|
|
71
|
-
|
|
72
|
-
# Read from stdin (defaults to TSV)
|
|
73
|
-
cat data.tsv | dv
|
|
74
|
-
dv < data.tsv
|
|
75
|
-
|
|
76
|
-
# Specify delimiter
|
|
77
|
-
dv data.txt -d '|'
|
|
78
|
-
|
|
79
|
-
# Gzipped files are supported
|
|
80
|
-
dv data.csv.gz
|
|
81
71
|
```
|
|
82
72
|
|
|
83
73
|
### Multi-File Usage - Multiple Tabs
|
|
@@ -101,20 +91,11 @@ dv data1.tsv < data2.tsv
|
|
|
101
91
|
dv *.parquet --all-in-one
|
|
102
92
|
```
|
|
103
93
|
|
|
104
|
-
When multiple files are opened:
|
|
105
|
-
- Each file appears as a separate tab. An Excel file may contain multiple tabs.
|
|
106
|
-
- Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
|
|
107
|
-
- Save current tab to file with `Ctrl+T`
|
|
108
|
-
- Save all tabs to file with `Ctrl+S`
|
|
109
|
-
- Duplicate the current tab with `Ctrl+D`
|
|
110
|
-
- Open additional files with `Ctrl+O`
|
|
111
|
-
- Each file maintains its own state (edits, sort order, selections, history, etc.) and allow undo/redo.
|
|
112
|
-
|
|
113
94
|
## Command Line Options
|
|
114
95
|
|
|
115
96
|
```
|
|
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]]
|
|
117
|
-
[--sql SQL] [-o OUTPUT]
|
|
97
|
+
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]]
|
|
98
|
+
[--all-in-one] [--sql SQL] [-o OUTPUT]
|
|
118
99
|
[files ...]
|
|
119
100
|
|
|
120
101
|
TUI viewer/editor for tabular data (e.g., CSV/Excel).
|
|
@@ -126,8 +107,11 @@ options:
|
|
|
126
107
|
-h, --help show this help message and exit
|
|
127
108
|
-V, --version show program's version number and exit
|
|
128
109
|
-d, --delimiter DELIMITER
|
|
129
|
-
Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`)
|
|
130
|
-
|
|
110
|
+
Specify the delimiter of the input files (must be a single character, e.g., `|` or `;`). By default, the delimiter is inferred from the file extension. If reading from stdin, the
|
|
111
|
+
delimiter must be specified unless it is tab delimited.
|
|
112
|
+
-f, --format FORMAT Specify the format of the input files (e.g., `csv` or `excel`). By default, the format is inferred from the file extension. If reading from stdin, the format must be specified
|
|
113
|
+
unless it is tab delimited.
|
|
114
|
+
-F, --fields [FIELDS ...]
|
|
131
115
|
When used without values, list available fields. Otherwise, read only specified fields.
|
|
132
116
|
-H, --header [HEADER ...]
|
|
133
117
|
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`).
|
|
@@ -159,11 +143,18 @@ options:
|
|
|
159
143
|
# Open a file
|
|
160
144
|
dv data.csv
|
|
161
145
|
|
|
162
|
-
#
|
|
146
|
+
# Gzipped files are supported
|
|
163
147
|
dv data.csv.gz
|
|
164
148
|
|
|
165
|
-
# Read from stdin
|
|
166
|
-
|
|
149
|
+
# Read from stdin (defaults to TSV)
|
|
150
|
+
cat data.tsv | dv
|
|
151
|
+
dv < data.tsv
|
|
152
|
+
|
|
153
|
+
# Specify delimiter
|
|
154
|
+
dv data.txt -d '|'
|
|
155
|
+
|
|
156
|
+
# Specify format
|
|
157
|
+
dv data.json -f ndjson
|
|
167
158
|
|
|
168
159
|
# View headless CSV file
|
|
169
160
|
dv data_no_header.csv -H
|
|
@@ -202,10 +193,10 @@ dv data.tsv -Q
|
|
|
202
193
|
dv data.csv --theme monokai
|
|
203
194
|
|
|
204
195
|
# Show column headers
|
|
205
|
-
dv data.csv -
|
|
196
|
+
dv data.csv -F
|
|
206
197
|
|
|
207
198
|
# Read only specific columns: 'name', 'age', first column, and last column
|
|
208
|
-
dv data.csv -
|
|
199
|
+
dv data.csv -F name age 1 -1
|
|
209
200
|
|
|
210
201
|
# Read all files (must be of same format and same structure) into one single table
|
|
211
202
|
dv data-1.csv data-2.csv --all-in-one
|
|
@@ -67,10 +67,15 @@ 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 `;`). By default, the delimiter is inferred from the file extension. If reading from stdin, the delimiter must be specified unless it is tab delimited.",
|
|
71
71
|
)
|
|
72
72
|
parser.add_argument(
|
|
73
73
|
"-f",
|
|
74
|
+
"--format",
|
|
75
|
+
help="Specify the format of the input files (e.g., `csv` or `excel`). By default, the format is inferred from the file extension. If reading from stdin, the format must be specified unless it is tab delimited.",
|
|
76
|
+
)
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
"-F",
|
|
74
79
|
"--fields",
|
|
75
80
|
nargs="*",
|
|
76
81
|
action=ConstWithMultiArgs,
|
|
@@ -166,10 +171,7 @@ def cli() -> argparse.Namespace:
|
|
|
166
171
|
)
|
|
167
172
|
|
|
168
173
|
args = parser.parse_args()
|
|
169
|
-
|
|
170
|
-
if args.delimiter and len(args.delimiter) != 1:
|
|
171
|
-
print("Delimiter must be a single character.", file=sys.stderr)
|
|
172
|
-
sys.exit(1)
|
|
174
|
+
validate_args(args)
|
|
173
175
|
|
|
174
176
|
# List available themes and exit
|
|
175
177
|
if args.theme == "list":
|
|
@@ -215,17 +217,10 @@ def cli() -> argparse.Namespace:
|
|
|
215
217
|
def main() -> None:
|
|
216
218
|
args = cli()
|
|
217
219
|
|
|
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
|
-
|
|
226
220
|
sources = load_dataframe(
|
|
227
221
|
args.files,
|
|
228
222
|
delimiter=args.delimiter,
|
|
223
|
+
format=args.format,
|
|
229
224
|
header=args.header,
|
|
230
225
|
infer_schema=not args.no_inference,
|
|
231
226
|
infer_schema_length=args.infer_schema_length,
|
|
@@ -261,12 +256,44 @@ def main() -> None:
|
|
|
261
256
|
|
|
262
257
|
# If output file is specified, write the (optionally modified) data to the output file and exit
|
|
263
258
|
if args.output:
|
|
264
|
-
return write_file(sources, args.output
|
|
259
|
+
return write_file(sources, args.output)
|
|
265
260
|
|
|
266
261
|
# Run the DataFrame Viewer application
|
|
267
262
|
app = DataFrameViewer(*sources, theme=args.theme)
|
|
268
263
|
handle_compute_error(app.run())
|
|
269
264
|
|
|
270
265
|
|
|
266
|
+
def validate_args(args: argparse.Namespace) -> None:
|
|
267
|
+
"""Validate command-line arguments and exit with an error message if invalid.
|
|
268
|
+
|
|
269
|
+
Checks for various argument conditions such as file existence, valid delimiters,
|
|
270
|
+
supported formats, and consistency between format and delimiter specifications.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
args: The parsed command-line arguments to validate.
|
|
274
|
+
"""
|
|
275
|
+
if args.delimiter and len(args.delimiter) != 1:
|
|
276
|
+
print("Delimiter must be a single character.", file=sys.stderr)
|
|
277
|
+
sys.exit(1)
|
|
278
|
+
|
|
279
|
+
if args.format and args.format not in SUPPORTED_FORMATS:
|
|
280
|
+
print(
|
|
281
|
+
f"Unsupported format: `{args.format}`. Supported formats: {', '.join(SUPPORTED_FORMATS)}", file=sys.stderr
|
|
282
|
+
)
|
|
283
|
+
sys.exit(1)
|
|
284
|
+
|
|
285
|
+
if args.delimiter and args.format:
|
|
286
|
+
print("Cannot specify both delimiter and format.", file=sys.stderr)
|
|
287
|
+
sys.exit(1)
|
|
288
|
+
|
|
289
|
+
if args.output:
|
|
290
|
+
if not guess_file_format(args.output):
|
|
291
|
+
print(
|
|
292
|
+
f"Unsupported output file format for `{args.output}`. Supported formats: {', '.join(SUPPORTED_FORMATS)}",
|
|
293
|
+
file=sys.stderr,
|
|
294
|
+
)
|
|
295
|
+
sys.exit(1)
|
|
296
|
+
|
|
297
|
+
|
|
271
298
|
if __name__ == "__main__":
|
|
272
299
|
main()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Common utilities and constants for dataframe_viewer."""
|
|
2
2
|
|
|
3
|
+
import json
|
|
3
4
|
import os
|
|
4
5
|
import re
|
|
5
6
|
import sys
|
|
@@ -662,6 +663,7 @@ def guess_file_format(filename: str | Path) -> str | None:
|
|
|
662
663
|
def load_dataframe(
|
|
663
664
|
filenames: list[str],
|
|
664
665
|
delimiter: str | None = None,
|
|
666
|
+
format: str | None = None,
|
|
665
667
|
header: bool | list[str] = True,
|
|
666
668
|
infer_schema: bool = True,
|
|
667
669
|
infer_schema_length: int | None = 100,
|
|
@@ -683,7 +685,8 @@ def load_dataframe(
|
|
|
683
685
|
|
|
684
686
|
Args:
|
|
685
687
|
filenames: List of filenames to load. If single filename is "-", read from stdin.
|
|
686
|
-
delimiter: Optional delimiter specifier for input files (e.g., ';' for SSV).
|
|
688
|
+
delimiter: Optional delimiter specifier for input files (e.g., ';' for SSV). Defaults to None (infer from file extension).
|
|
689
|
+
format: Optional format specifier for input files (e.g., 'csv' or 'excel'). Defaults to None (infer from file extension).
|
|
687
690
|
header: Specify header info. for CSV/TSV files. Can be True (header in first line), False (no header, auto-generate column names), or list of column names to use. Defaults to True.
|
|
688
691
|
infer_schema: Whether to infer data types for CSV/TSV files. Defaults to True.
|
|
689
692
|
infer_schema_length: Number of rows to use for schema inference when infer_schema is True. Defaults to 100.
|
|
@@ -727,6 +730,7 @@ def load_dataframe(
|
|
|
727
730
|
source,
|
|
728
731
|
prefix_sheet=prefix_sheet,
|
|
729
732
|
delimiter=delimiter,
|
|
733
|
+
format=format,
|
|
730
734
|
header=header,
|
|
731
735
|
infer_schema=infer_schema,
|
|
732
736
|
infer_schema_length=infer_schema_length,
|
|
@@ -758,6 +762,7 @@ def load_file(
|
|
|
758
762
|
first_sheet: bool = False,
|
|
759
763
|
prefix_sheet: bool = False,
|
|
760
764
|
delimiter: str | None = None,
|
|
765
|
+
format: str | None = None,
|
|
761
766
|
header: bool | list[str] = True,
|
|
762
767
|
infer_schema_length: int | None = 100,
|
|
763
768
|
infer_schema: bool = True,
|
|
@@ -785,6 +790,7 @@ def load_file(
|
|
|
785
790
|
first_sheet: If True, only load first sheet for Excel files. Defaults to False.
|
|
786
791
|
prefix_sheet: If True, prefix filename to sheet name as the tab name for Excel files. Defaults to False.
|
|
787
792
|
delimiter: Optional delimiter specifier for input files (e.g., ';' for SSV). Defaults to None (infer from file extension).
|
|
793
|
+
format: Optional format specifier for input files (e.g., 'csv' or 'excel'). Defaults to None (infer from file extension).
|
|
788
794
|
header: Specify header info. for the input file. Can be True (header in first line), False (no header, auto-generate column names), or list of column names to use.
|
|
789
795
|
infer_schema: Whether to infer data types for CSV/TSV files. Defaults to True.
|
|
790
796
|
infer_schema_length: Number of rows to use for inferring schema when reading CSV/TSV. Defaults to 100.
|
|
@@ -804,13 +810,8 @@ def load_file(
|
|
|
804
810
|
"""
|
|
805
811
|
data: list[Source] = []
|
|
806
812
|
|
|
807
|
-
fmt = None if delimiter else guess_file_format(source)
|
|
808
|
-
|
|
809
|
-
if delimiter:
|
|
810
|
-
fmt = None
|
|
811
|
-
else:
|
|
812
|
-
# Default to TSV if format cannot be determined
|
|
813
|
-
fmt = guess_file_format(source) or "tsv"
|
|
813
|
+
fmt = format or (None if delimiter else guess_file_format(source) or "tsv")
|
|
814
|
+
if fmt:
|
|
814
815
|
delimiter = SUPPORTED_FORMATS.get(fmt)
|
|
815
816
|
|
|
816
817
|
filename = f"stdin.{fmt}" if isinstance(source, StringIO) else source
|
|
@@ -873,13 +874,23 @@ def load_file(
|
|
|
873
874
|
lf = pl.scan_parquet(source, n_rows=n_rows)
|
|
874
875
|
data.append(Source(lf, filename, filepath.stem))
|
|
875
876
|
elif fmt in ("jsonl", "ndjson"):
|
|
877
|
+
# https://github.com/pola-rs/polars/issues/23023
|
|
878
|
+
# read_ndjson does not retain column order for 33 or more columns
|
|
879
|
+
if isinstance(source, StringIO):
|
|
880
|
+
line = source.readline()
|
|
881
|
+
ordered_columns = json.loads(line).keys() # Get column order from the first line
|
|
882
|
+
source.seek(0) # Reset StringIO to the beginning after validation
|
|
883
|
+
else:
|
|
884
|
+
with open(source) as f:
|
|
885
|
+
line = f.readline()
|
|
886
|
+
ordered_columns = json.loads(line).keys() # Get column order from the first line
|
|
876
887
|
lf = pl.scan_ndjson(
|
|
877
888
|
source,
|
|
878
889
|
n_rows=n_rows,
|
|
879
890
|
infer_schema_length=infer_schema_length,
|
|
880
891
|
ignore_errors=ignore_errors,
|
|
881
892
|
)
|
|
882
|
-
data.append(Source(lf, filename, filepath.stem))
|
|
893
|
+
data.append(Source(lf.select(ordered_columns), filename, filepath.stem))
|
|
883
894
|
elif fmt == "json":
|
|
884
895
|
try:
|
|
885
896
|
df = pl.read_json(source)
|
|
@@ -920,7 +931,14 @@ def load_file(
|
|
|
920
931
|
return data
|
|
921
932
|
|
|
922
933
|
|
|
923
|
-
def write_file(sources: list[Source], filename: str
|
|
934
|
+
def write_file(sources: list[Source], filename: str) -> None:
|
|
935
|
+
if not (fmt := guess_file_format(filename)):
|
|
936
|
+
print(
|
|
937
|
+
f"Unsupported output file format for `{filename}`. Supported formats: {', '.join(SUPPORTED_FORMATS)}",
|
|
938
|
+
file=sys.stderr,
|
|
939
|
+
)
|
|
940
|
+
sys.exit(1)
|
|
941
|
+
|
|
924
942
|
if len(sources) > 1 and fmt not in ("xlsx", "xls"):
|
|
925
943
|
print("Only Excel formats (.xlsx, .xls) support multiple tabs", file=sys.stderr)
|
|
926
944
|
sys.exit(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_help_panel.py
RENAMED
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_table.py
RENAMED
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/data_frame_viewer.py
RENAMED
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/file_picker_screen.py
RENAMED
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/loading_screen.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataframe_textual-2.36.0 → dataframe_textual-2.37.0}/src/dataframe_textual/yes_no_screen.py
RENAMED
|
File without changes
|
|
File without changes
|