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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumry
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A data summarization tool for analyzing various file formats
5
5
  Author: Sparkgeo
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sumry"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "A data summarization tool for analyzing various file formats"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -82,18 +82,33 @@ class XLSX(BaseFormat):
82
82
 
83
83
  # Read sample data from the specified layer
84
84
  try:
85
- sample_query = f"""
86
- SELECT * FROM st_read('{self.file}', layer='{self.layer}')
87
- LIMIT {count}
88
- """
89
- df = duckdb.sql(sample_query).df()
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 {min(count, len(df))} of {count} requested records)")
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumry
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A data summarization tool for analyzing various file formats
5
5
  Author: Sparkgeo
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes