======================== CODE SNIPPETS ======================== TITLE: Inno Setup Script for VisiData Installer (Windows) DESCRIPTION: This refers to the `vd.iss` script, which is an Inno Setup configuration file used to define the parameters for building the VisiData Windows installer. It specifies installation paths, files to include, and other installer properties. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_8 LANGUAGE: Inno Setup Script CODE: ``` vd.iss ``` ---------------------------------------- TITLE: Example VisiData Guide Content for Macros DESCRIPTION: This snippet provides a complete example of the content for a VisiData guide, including the YAML front matter and the main body. It illustrates how to describe a feature (Macros), outline basic usage steps, and reference VisiData commands using the '{help.commands.command-name}' syntax for auto-completion and linking within the application. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/api/guides.rst#_snippet_1 LANGUAGE: Markdown CODE: ``` --- sheettype: Sheet --- # Macros Macros allow you to bind a command sequence to a keystroke or longname, to replay when that keystroke is pressed or the command is executed by longname. The basic usage is: 1. {help.commands.macro-record} 2. Execute a series of commands. 3. `m` again to complete the recording, and prompt for the keystroke or longname to bind it to. # The Macros Sheet - {help.commands.macro-sheet} - `d` (`delete-row`) to mark macros for deletion. - {help.commands.commit_sheet} - `Enter` (`open-row`) to open the macro in the current row, and view the series of commands composing it. ''' ``` ---------------------------------------- TITLE: Installing VisiData with Test Dependencies (Shell) DESCRIPTION: This command sequence clones the VisiData repository from GitHub, navigates into the directory, and then installs VisiData along with its specific test dependencies using pip3. This setup is essential before running any tests. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/test.md#_snippet_0 LANGUAGE: Shell CODE: ``` git clone https://github.com/saulpw/visidata.git cd visidata pip3 install ".[test]" ``` ---------------------------------------- TITLE: Installing VisiData Develop Branch via pip (Windows) DESCRIPTION: This command installs the development version of VisiData directly from its Git repository's `develop` branch. It requires Git to be installed and is used for testing the latest features or contributing to the project. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_2 LANGUAGE: Shell CODE: ``` pip3 install git+https://github.com/saulpw/visidata.git@develop ``` ---------------------------------------- TITLE: Installing PyInstaller via pip (Windows) DESCRIPTION: This command installs PyInstaller, a tool used to bundle Python applications into standalone executables. It is a prerequisite for compiling VisiData into a single executable file for distribution. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_4 LANGUAGE: Shell CODE: ``` ./Scripts/pip3.exe install pyinstaller ``` ---------------------------------------- TITLE: Installing VisiData via pip (Windows) DESCRIPTION: This command uses the `pip3` package installer from the WinPY environment to install the stable version of VisiData. It ensures that VisiData and its core dependencies are available for use. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_1 LANGUAGE: Shell CODE: ``` ./Scripts/pip3.exe install visidata ``` ---------------------------------------- TITLE: Installing VisiData Latest Release (Python) DESCRIPTION: This command installs the latest stable release of VisiData from PyPi using pip3. It is the recommended way to get VisiData for general use and ensures you have the most recent stable features and bug fixes. SOURCE: https://github.com/saulpw/visidata/blob/develop/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` pip3 install visidata ``` ---------------------------------------- TITLE: Initial Pivot Table Example in VisiData DESCRIPTION: This snippet shows an example of a pivot table in VisiData, created by pivoting columns `R`, `B` with `date` as the key, and using `sum` and `mean` aggregators. It serves as the starting point for melt operations. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/guides/MeltGuide.md#_snippet_0 LANGUAGE: VisiData Table CODE: ``` date sum_R mean_R sum_B mean_B ---------- ----- ------ ----- ------ 2024-09-01 30 30 0 2024-09-02 0 28 28 2024-09-03 100 100 132 66 ``` ---------------------------------------- TITLE: Starting VisiData at Specific Sheet, Row, Column DESCRIPTION: This command loads an XLSX file (`sample-sales-reps.xlsx`) and uses the `+:` syntax to specify an initial sheet (`sample-salesv4`), row (`2`), and column (`3`) to start at. This tests VisiData's ability to open a file at a precise location. SOURCE: https://github.com/saulpw/visidata/blob/develop/dev/checklists/manual-tests.md#_snippet_8 LANGUAGE: Shell CODE: ``` bin/vd +:sample-salesv4:2:3 sample_data/sample-sales-reps.xlsx ``` ---------------------------------------- TITLE: Installing VisiData Develop Branch (Python) DESCRIPTION: This command installs the cutting-edge `develop` branch of VisiData directly from its GitHub repository. This version may contain the latest features and experimental changes but comes with no warranty and might be less stable. SOURCE: https://github.com/saulpw/visidata/blob/develop/README.md#_snippet_1 LANGUAGE: Shell CODE: ``` pip3 install git+https://github.com/saulpw/visidata.git@develop ``` ---------------------------------------- TITLE: Cloning VisiData Windows Installer Repository (Windows) DESCRIPTION: This command clones the `vdwin` repository, which contains scripts and resources specific to packaging VisiData for Windows, into the `WinPy/vdwin` directory. This repository is essential for the PyInstaller build process. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_5 LANGUAGE: Shell CODE: ``` git clone https://github.com/saulpw/vdwin.git WinPy/vdwin ``` ---------------------------------------- TITLE: Compiling VisiData Executable with PyInstaller (Windows) DESCRIPTION: This command uses PyInstaller to compile the VisiData application into a single executable file. It specifies the output name, an icon, and the main VisiData Python script, creating a standalone `visidata.exe`. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_6 LANGUAGE: Shell CODE: ``` ./Scripts/pyinstaller.exe --onefile/-F --icon/-i ..\vdwin\vdicon.ico --name/-n VisiData ..\vdwin\visidata.py ``` ---------------------------------------- TITLE: Installing Ibis PostgreSQL Backend DESCRIPTION: This command installs the PostgreSQL backend for Ibis, which is required for `vdsql` to connect to PostgreSQL databases. By default, only the SQLite backend is included, and other backends must be installed separately to enable their support. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/vdsql/README.md#_snippet_2 LANGUAGE: Shell CODE: ``` pip install 'ibis-framework[postgres]' ``` ---------------------------------------- TITLE: Installing vdsql Manually (Development Version) DESCRIPTION: These commands allow for a manual installation of the cutting-edge development version of `vdsql` directly from the VisiData Git repository. This method is suitable for developers or users who need the very latest features and are comfortable with a potentially less stable build. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/vdsql/README.md#_snippet_1 LANGUAGE: Shell CODE: ``` git clone git@github.com:saulpw/visidata.git cd visidata/visidata/apps/vdsql pip3 install . ``` ---------------------------------------- TITLE: Starting Galactic Conquest Server (Shell) DESCRIPTION: This command starts the Galactic Conquest game server. The optional `-p` flag allows specifying a custom port; otherwise, it defaults to 8080. The server will output a URL for clients to connect. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/galcon/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` ./galcon-server.py [-p ] ``` ---------------------------------------- TITLE: Installing Windows Curses for VisiData (Windows) DESCRIPTION: This command installs the `windows-curses` library, which provides `curses` compatibility on Windows. This dependency is crucial for VisiData's terminal-based user interface to function correctly. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_3 LANGUAGE: Shell CODE: ``` ./Scripts/pip3.exe install windows-curses ``` ---------------------------------------- TITLE: Example Nested Data for VisiData Column Expansion DESCRIPTION: This JSON array provides an example of nested data structures, including arrays and objects, that VisiData's `(` family of commands can expand into top-level columns. It demonstrates various levels of nesting for testing expansion capabilities. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/columns.md#_snippet_23 LANGUAGE: JSON CODE: ``` [ [ "short", "array" ], [ "slightly", "longer", "array" ], { "nested": "data" }, { "more": { "deeply": { "nested": "data" } } } ] ``` ---------------------------------------- TITLE: Programmatically Setting Options in VisiData DESCRIPTION: Provides examples of programmatically setting options in VisiData, demonstrating how to set sheet-specific, global, or type-specific options. SOURCE: https://github.com/saulpw/visidata/blob/develop/dev/design/169-settings.md#_snippet_10 LANGUAGE: Python CODE: ``` .options.my_option = "value" options.my_option = "global default" Canvas.options.my_option = 42 ``` ---------------------------------------- TITLE: Navigating to WinPY Python Directory (Windows) DESCRIPTION: This command changes the current directory to the WinPY Python installation path, which is a prerequisite for running Python scripts and commands within the WinPython environment. SOURCE: https://github.com/saulpw/visidata/blob/develop/platform/windows/vdwin-installer.md#_snippet_0 LANGUAGE: Shell CODE: ``` cd WinPY\python-3.9.4.amd64 ``` ---------------------------------------- TITLE: Installing vdsql Latest Release DESCRIPTION: This command installs the latest stable release of `vdsql`, which includes the `vd` command with the `vdsql` plugin enabled and a dedicated `vdsql` script. It allows VisiData to use Ibis for database loading instead of its built-in loaders. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/vdsql/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` pip install vdsql ``` ---------------------------------------- TITLE: Installing vgit via pip DESCRIPTION: This command installs the vgit package directly from its GitHub repository using pip. It specifies the branch and subdirectory to ensure the correct module is installed, along with its VisiData dependency. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/vgit/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` pip install git+https://github.com/saulpw/visidata.git@branch#subdirectory=visidata/apps/vgit ``` ---------------------------------------- TITLE: Installing the rvisidata R Package (R) DESCRIPTION: This R command installs the 'rvisidata' package directly from GitHub using 'devtools::install_github()'. This package provides the bridge for opening R data frames within VisiData. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/loading.md#_snippet_5 LANGUAGE: R CODE: ``` devtools::install_github('paulklemm/rvisidata') ``` ---------------------------------------- TITLE: Accessing Command and Binding Dictionaries DESCRIPTION: Provides examples of how to access dictionaries containing all available commands and keybindings, either globally or specific to a SheetType or the VisiData (vs) object. SOURCE: https://github.com/saulpw/visidata/blob/develop/dev/design/169-settings.md#_snippet_6 LANGUAGE: Python CODE: ``` commands SheetType.commands vs.commands bindings SheetType.bindings ``` ---------------------------------------- TITLE: Starting New Branch (vgit) DESCRIPTION: Creates a new Git branch. This action is equivalent to `git branch `. SOURCE: https://github.com/saulpw/visidata/blob/develop/visidata/apps/vgit/vgit-guide.md#_snippet_3 LANGUAGE: Git CODE: ``` git branch ``` ---------------------------------------- TITLE: Example: Filtering Rows by Item and Units in VisiData DESCRIPTION: Demonstrates a specific workflow to filter rows based on multiple conditions (Item and Units) using VisiData's `z|` command and then open a new sheet with the filtered results. Requires setting column type. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/rows.md#_snippet_2 LANGUAGE: VisiData CODE: ``` # z| Item == 'Binder' and Units < 10 " ``` ---------------------------------------- TITLE: Defining and Binding a Custom VisiData Command (Python) DESCRIPTION: This example illustrates how to create a custom API method (`show_hello`) for VisiData sheets, register it as a command (`show-hello`), and then bind multiple keyboard shortcuts (Shift+H, Ctrl+H, Alt+H) to execute this command. It shows the full lifecycle from function definition to user interaction via keybindings. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/api/commands.rst#_snippet_1 LANGUAGE: Python CODE: ``` @Sheet.api def show_hello(sheet): vd.status(sheet.options.disp_hello) # `sheet` members and `vd` members are available in the execstr scope BaseSheet.addCommand(None, 'show-hello', 'show_hello()', 'show a warm greeting') # bind Shift+H, Ctrl+H, and Alt+H to this command BaseSheet.bindkey('H', 'show-hello') BaseSheet.bindkey('^H', 'show-hello') BaseSheet.bindkey(ALT+'h', 'show-hello') ``` ---------------------------------------- TITLE: Documenting VisiData Options DESCRIPTION: This pattern outlines the standard format for documenting VisiData options. It includes a clickable link to the options sheet, the option's name formatted as code, its help string, and its default value. This structure ensures comprehensive and interactive documentation for VisiData configuration options. SOURCE: https://github.com/saulpw/visidata/blob/develop/docs/api/style.rst#_snippet_6 LANGUAGE: VisiData Documentation Pattern CODE: ``` [:onclick options-sheet