Restructure repository: organize tools by purpose, create what search tool
- Move single-file tools to tools/ organized by category (security, forensics, data, etc.) - Move multi-file projects to projects/ (go-tools, puzzlebox, timesketch, rust-tools) - Move system scripts to scripts/ (proxy, display, setup, windows) - Organize config files in config/ (shell, visidata, applications) - Move experimental tools to archive/experimental - Create 'what' fuzzy search tool with progressive enhancement (ollama->fzf->grep) - Add initial metadata database for intelligent tool discovery - Preserve git history using 'git mv' commands
This commit is contained in:
41
config/visidata/plugins/hidecol.py
Normal file
41
config/visidata/plugins/hidecol.py
Normal file
@@ -0,0 +1,41 @@
|
||||
__version__ = "0.1.0"
|
||||
__author__ = "Tabledevil <tabledevil@gmail.com>"
|
||||
|
||||
from visidata import Sheet, BaseSheet, vd
|
||||
|
||||
|
||||
@Sheet.api
|
||||
def hide_empty_and_superfluous_cols(sheet):
|
||||
"""
|
||||
Given a sheet, hides columns that are empty or superfluous (contain the same
|
||||
value in every row).
|
||||
"""
|
||||
# Count how many columns were hidden
|
||||
counter = 0
|
||||
# Check each column for being empty or superfluous
|
||||
for col in sheet.visibleCols:
|
||||
# If the column is not hidden
|
||||
if col.width and col.width > 0:
|
||||
# Check if the column is empty (all cells are empty or None)
|
||||
if all([col.getValue(row) in (None, "", "null") for row in sheet.rows]):
|
||||
# Hide the column
|
||||
col.width = 0
|
||||
counter += 1
|
||||
# Skip the next check for same values since all cells are empty or None
|
||||
continue
|
||||
|
||||
# Check if the column is superfluous (contains the same value in every row)
|
||||
# collect all values in the column as strings
|
||||
values = set([f'{col.getValue(row)}' for row in sheet.rows if col.getValue(row) not in (None, "", "null")])
|
||||
# If there is only one value in the column
|
||||
if len(values) == 1:
|
||||
# Hide the column
|
||||
col.width = 0
|
||||
counter += 1
|
||||
|
||||
vd.status(f"Hid {counter} empty/superfluous columns.")
|
||||
else:
|
||||
vd.status("No empty/superfluous columns to hide.")
|
||||
|
||||
Sheet.addCommand(None, "tke-hidecol", "sheet.hide_empty_and_superfluous_cols()")
|
||||
|
||||
Reference in New Issue
Block a user