Go to file
Cannae E. W. A. Hyphen 2d2fc311ad
Merge 172e9a4d5c into 60f95a1a74
2025-06-16 11:11:47 -07:00
.github Added psutil version info field [ci skip] 2020-07-13 11:30:27 +02:00
DEB Remove extra space 2020-07-22 12:00:45 +02:00
Imgs Added links to bpytop 2020-08-02 20:30:40 +02:00
src Fixed psutil script crash on OSX 2020-07-14 17:34:24 +02:00
test newline at EOF 2020-06-01 11:45:11 -06:00
themes Added missing # from hex value 2020-06-29 14:56:37 +02:00
.editorconfig Added 2020-05-07 18:23:17 +02:00
.gitignore added .gitignore for files created by DEB/build 2020-04-30 11:30:53 +02:00
.gitmodules added bats 2020-05-31 19:53:47 -06:00
.travis.yml newline at EOF 2020-06-01 11:45:11 -06:00
CHANGELOG.md v0.9.25 Fix for crash on linux when 9p filesystem is present 2020-07-20 12:35:57 +02:00
CODE_OF_CONDUCT.md Added 2020-05-07 19:45:06 +02:00
CONTRIBUTING.md Added info for bug fixing [skip ci] 2020-07-20 12:44:54 +02:00
LICENSE added 2020-04-05 20:31:04 +02:00
Makefile Change PREFIX /usr by /usr/local 2020-05-05 21:56:32 -03:00
README.md feat: Add Bash TUI Data Viewer 2025-06-16 17:28:13 +00:00
bashtop v0.9.25 Fix for crash on linux when 9p filesystem is present 2020-07-20 12:35:57 +02:00
dataviewer.sh feat: Add Bash TUI Data Viewer 2025-06-16 17:28:13 +00:00
requirements.txt newline at EOF 2020-06-01 11:45:11 -06:00
test.sh newline at EOF 2020-06-01 11:45:11 -06:00

README.md

Bash Data Viewer

A TUI (Text-based User Interface) tool, written purely in Bash, for displaying CSV, TSV, or JSON data. The display refreshes at a configurable interval, inspired by tools like bashtop.

Features

  • Displays CSV, TSV, and JSON data in a tabular format.
  • Configurable refresh interval for the data display.
  • Basic TUI for easy viewing in the terminal.
  • Error handling for file issues and unsupported formats.

Dependencies

  • Bash: Version 4.4 or later.
  • jq: Required for parsing JSON files. You can usually install it via your system's package manager (e.g., sudo apt install jq, sudo yum install jq, brew install jq).

Usage

To use the Bash Data Viewer, run the script from your terminal:

./dataviewer.sh [path_to_data_file] [refresh_interval_seconds]

Arguments:

  • path_to_data_file (optional): The path to the CSV, TSV, or JSON file you want to display.
    • If not provided, the TUI will launch and show "No input file specified."
  • refresh_interval_seconds (optional): The time in seconds between display refreshes.
    • Defaults to 5 seconds if not provided.
    • Must be a positive integer.

Examples:

  • Display a CSV file with a 2-second refresh interval:
    ./dataviewer.sh data.csv 2
    
  • Display a JSON file with the default 5-second refresh interval:
    ./dataviewer.sh logs.json
    
  • Launch the TUI without an initial file (it will show an appropriate message):
    ./dataviewer.sh
    

Supported Data Formats

CSV (Comma-Separated Values)

  • File extension must be .csv.
  • The first line is treated as the header row.
  • Uses comma (,) as the delimiter.

TSV (Tab-Separated Values)

  • File extension must be .tsv.
  • The first line is treated as the header row.
  • Uses tab (\t) as the delimiter.

JSON (JavaScript Object Notation)

  • File extension must be .json.
  • Requires jq to be installed.
  • Supported Structures:
    1. Array of Objects:
      • Example: [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 24}]
      • The keys of the first object in the array are used as headers.
      • Each object in the array is displayed as a row.
    2. Single Object:
      • Example: {"hostname": "server1", "ip": "192.168.1.10", "status": "running"}
      • The keys of the object are used as headers.
      • The object's values are displayed as a single data row.
    3. Empty Array:
      • Example: []
      • Displays an info message: "Info: JSON file is an empty array []".
  • Other JSON structures (e.g., simple arrays of strings/numbers, nested complex objects without a clear tabular mapping) might show an "Unsupported JSON structure" error or may not display as intended.

Controls

  • q: Quit the application.
  • r: Manually re-parse the input file and refresh the display. This is useful if the data file has been updated.

Error Handling

The TUI will display messages for common errors, such as:

  • File not found.
  • Unknown file type.
  • jq not installed (for JSON files).
  • Empty or invalid JSON files.
  • Unsupported JSON structures.

TODO / Potential Future Enhancements

  • More sophisticated column width calculation (e.g., based on content).
  • Scrolling (up/down, left/right) for larger datasets.
  • Configuration file for persistent settings.
  • Theming support.
  • Search/filter data within the TUI.