Skip to content

Commit

Permalink
Add number of columns subtitle (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: thread53 <[email protected]>
  • Loading branch information
thread53 and thread53 authored Aug 2, 2024
1 parent 67d4588 commit 40fcc25
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pqviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ def watch_theme(self):
datatable_schema.styles.scrollbar_color_active = color_hex
datatable_schema.styles.scrollbar_color_hover = color_hex
datatable_schema.border_title = "Schema"
datatable_schema.border_subtitle = f"Total columns: {self.parsed_file.number_columns()}"

datatable_content = self.query_one("#datatable_content")
datatable_content.styles.border = ("heavy", color_hex)
datatable_content.styles.scrollbar_color = color_hex
datatable_content.styles.scrollbar_color_active = color_hex
datatable_content.styles.scrollbar_color_hover = color_hex
datatable_content.border_title = "Table"
datatable_content.border_subtitle = f"Total rows: {len(self.parsed_file)}"
datatable_content.border_subtitle = f"Total rows: {self.parsed_file.number_rows()}"

def action_help_screen(self) -> None:
"""Action to display the help screen dialog."""
Expand Down
10 changes: 8 additions & 2 deletions pqviewer/file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ def schema(self) -> List[tuple]:
for name in self.table.column_names
]

def number_columns(self) -> int:
"""Get number of columns."""
return self.table.num_columns

def number_rows(self) -> int:
"""Get number of rows."""
return self.table.num_rows

def to_table(self) -> List[tuple]:
"""Transform table content to list."""

table_header = [tuple(self.table.column_names)]
table_content = [tuple(row.values()) for row in self.table.to_pylist()]
return table_header + table_content

def __len__(self) -> int:
return len(self.table)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pqviewer"
version = "0.2.6"
version = "0.2.7"
description = "View Apache Parquet Files In Your Terminal"
authors = ["thread53 <[email protected]>"]
license = "MIT"
Expand All @@ -16,7 +16,7 @@ classifiers = [
[tool.poetry.dependencies]
python = "^3.8"
textual = "==0.46.0"
pyarrow = "==14.0.1"
pyarrow = ">=17.0.0"


[build-system]
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==8.0.0
textual==0.46.0
pyarrow==14.0.1
pyarrow>=17.0.0

0 comments on commit 40fcc25

Please sign in to comment.