CSV Codeblock
by elrindir
Score: 41/100
favorite
share
Description
Category: Data Visualization

The CSV Codeblock plugin is a game-changer for Obsidian users who work with data-heavy notes. With this plugin, you can effortlessly convert CSV codeblocks into tables within your notes, making it easier to analyze and visualize your data. Simply wrap your CSV data in a codeblock and identify it as csv, and the plugin will take care of rendering it as a table. This feature is particularly useful for those who work with spreadsheets, financial data, or any other type of data that requires tabular representation. With the CSV Codeblock plugin, you can easily turn complex CSV data into an intuitive and easy-to-understand format within Obsidian.

Stats
9
stars
4,096
downloads
1
forks
510
days
256
days
256
days
1
total PRs
0
open PRs
0
closed PRs
1
merged PRs
3
total issues
2
open issues
1
closed issues
2
commits
Latest Version
8 months ago
Changelog

Now supports tsv in codeblocks. Thanks mklepaczewski for the request.

README file from

CSV Codeblock

This is a plugin for Obsidian (https://obsidian.md). This plugin renders codeblocks with csv format as tables.

Usage

Just put the csv identifyer in a codeblock:

```csv
Pos, Date, Name, Price
1, 2023-09-28, Spices, 150$
2, 2023-02-29, Shovel, 1.25$
```

A preview of the rendered table

Stolen Code

I stole the code from https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing#Post-process+Markdown+code+blocks

import { Plugin } from "obsidian";

export default class ExamplePlugin extends Plugin {
  async onload() {
    this.registerMarkdownCodeBlockProcessor("csv", (source, el, ctx) => {
      const rows = source.split("\n").filter((row) => row.length > 0);

      const table = el.createEl("table");
      const body = table.createEl("tbody");

      for (let i = 0; i < rows.length; i++) {
        const cols = rows[i].split(",");

        const row = body.createEl("tr");

        for (let j = 0; j < cols.length; j++) {
          row.createEl("td", { text: cols[j] });
        }
      }
    });
  }
}

Changelog

v1.1 Added TSV Support

on Jul 18, 2024

Now supports tsv in codeblocks. Thanks mklepaczewski for the request.

v1.0 Initial Release

on Sep 28, 2023