sumry 0.2.0__tar.gz → 0.3.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.
- {sumry-0.2.0/src/sumry.egg-info → sumry-0.3.0}/PKG-INFO +1 -1
- {sumry-0.2.0 → sumry-0.3.0}/pyproject.toml +1 -1
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/formats/xlsx.py +23 -8
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/main.py +1 -1
- {sumry-0.2.0 → sumry-0.3.0/src/sumry.egg-info}/PKG-INFO +1 -1
- {sumry-0.2.0 → sumry-0.3.0}/LICENSE +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/README.md +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/setup.cfg +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/__init__.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/cli.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/formats/__init__.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/formats/base.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/readers.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry/timing.py +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry.egg-info/SOURCES.txt +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry.egg-info/dependency_links.txt +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry.egg-info/entry_points.txt +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry.egg-info/requires.txt +0 -0
- {sumry-0.2.0 → sumry-0.3.0}/src/sumry.egg-info/top_level.txt +0 -0
|
@@ -82,18 +82,33 @@ class XLSX(BaseFormat):
|
|
|
82
82
|
|
|
83
83
|
# Read sample data from the specified layer
|
|
84
84
|
try:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
abs_count = abs(count)
|
|
86
|
+
|
|
87
|
+
if count < 0:
|
|
88
|
+
# Get last N records by using row number and ordering
|
|
89
|
+
sample_query = f"""
|
|
90
|
+
SELECT * EXCLUDE (_rn) FROM (
|
|
91
|
+
SELECT *, ROW_NUMBER() OVER () as _rn
|
|
92
|
+
FROM st_read('{self.file}', layer='{self.layer}')
|
|
93
|
+
) ORDER BY _rn DESC LIMIT {abs_count}
|
|
94
|
+
"""
|
|
95
|
+
df = duckdb.sql(sample_query).df()
|
|
96
|
+
# Reverse to show in original order
|
|
97
|
+
df = df.iloc[::-1].reset_index(drop=True)
|
|
98
|
+
else:
|
|
99
|
+
sample_query = f"""
|
|
100
|
+
SELECT * FROM st_read('{self.file}', layer='{self.layer}')
|
|
101
|
+
LIMIT {abs_count}
|
|
102
|
+
"""
|
|
103
|
+
df = duckdb.sql(sample_query).df()
|
|
104
|
+
|
|
91
105
|
if df.empty:
|
|
92
106
|
console.print(f"[yellow]No data found in layer '{self.layer}'[/yellow]")
|
|
93
107
|
return
|
|
94
|
-
|
|
108
|
+
|
|
109
|
+
position = "last" if count < 0 else "first"
|
|
95
110
|
# Create a Rich table
|
|
96
|
-
table = Table(title=f"Sample data from '{self.layer}' (showing {
|
|
111
|
+
table = Table(title=f"Sample data from '{self.layer}' (showing {position} {len(df)} records)")
|
|
97
112
|
|
|
98
113
|
# Add columns to the table
|
|
99
114
|
for col in df.columns:
|
|
@@ -18,7 +18,7 @@ def info(
|
|
|
18
18
|
def sample(
|
|
19
19
|
file: str = typer.Argument(..., help="Source file."),
|
|
20
20
|
layer: str = typer.Argument(None, help="Layer name."),
|
|
21
|
-
count: int = typer.Option(5, "--count", "-n", help="Number of sample records to display."),
|
|
21
|
+
count: int = typer.Option(5, "--count", "-n", help="Number of sample records to display. Use negative values to show records from the end (e.g., -5 for last 5 records)."),
|
|
22
22
|
):
|
|
23
23
|
xlsx = XLSX(file, layer=layer)
|
|
24
24
|
xlsx.sample(count=count)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|