Skip to main content

Read and query Obsidian Base (.base) files from Python

Project description

obsbase

Read and query Obsidian Bases from Python.

obsbase loads Obsidian .base files and returns the results as Python objects or pandas DataFrames.

Installation

pip install obsbase

Quick start

from obsbase import Vaultvault = Vault("/path/to/your/vault")df = (    vault    .base("books.base")    .run()    .to_dataframe())print(df.head())

Description

Vault
   │
   ├── notes()
   │
   └── base("books.base")
            │
            ▼
          Base
            │
            ▼
          View
            │
            ▼
        ResultSet
            │
            ▼
       pandas.DataFrame

Example

example vault with french cities:

set md files from wikipedia : https://fr.wikipedia.org/wiki/Liste_des_communes_de_France_les_plus_peupl%C3%A9es

villes/    Paris.md    Lyon.md    Marseille.md

top50.base

views:
  - type: table
    name: Tableau
    filters:
      and:
        - file.folder == "villes"
        - Rang_2023 <= 50
    order:
      - file.name
      - Commune
      - Population_de_référence
      - Département
      - Région
      - Rang_2023
    sort:
      - property: Rang_2023
        direction: ASC

Then:

from obsbase import Vault

vault = Vault("examples/obsbase_vault")

base = vault.base("top50.base")

rows = base.run()

df = rows.to_dataframe()

returns

file.name Commune Population_de_référence Département Région Rang_2023
0 Reims Reims 177 674 Marne Grand Est 13
1 Amiens Amiens 136 449 Somme Hauts-de-France 28
2 Avignon Avignon 92 188 Vaucluse Provence-Alpes-Côte d'Azur 49
3 Tourcoing Tourcoing 98 772 Nord Hauts-de-France 43
4 Roubaix Roubaix 98 286 Nord Hauts-de-France 44
5 Villeurbanne Villeurbanne 163 684 Métropole de Lyon Auvergne-Rhône-Alpe 16
... ... ... ... ... ... ...
45 Paris Paris 2 103 778 Paris Île-de-France 1
46 Perpignan Perpignan 121 616 Pyrénées-Orientales Occitanie 32
47 Strasbourg Strasbourg 293 771 Bas-Rhin Grand Est 8
48 Aix-en-Provence Aix-en-Provence 149 695 Bouches-du-Rhône Provence-Alpes-Côte d'Azur 22
49 Toulouse Toulouse 514 819 Haute-Garonne Occitanie 4

API

Vault

vault = Vault(path)

Methods

  • notes()
  • base(filename)

Base

base = vault.base("top50.base")

Methods

  • run()

Attributes

  • views

View

view = base.views[0]

Methods

  • run()

Attributes

  • name
  • type
  • filters
  • columns
  • sort

ResultSet

rows = base.run()

Methods

  • to_dataframe()

Supports

  • iteration
  • indexing
  • len()

Roadmap

  • Read notes
  • Read .base files
  • Execute filters
  • Export to pandas
  • Sorting
  • Nested filters (or)
  • Dataview expressions
  • CSV export
  • Markdown export

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obsbase-0.1.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obsbase-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file obsbase-0.1.2.tar.gz.

File metadata

  • Download URL: obsbase-0.1.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for obsbase-0.1.2.tar.gz
Algorithm Hash digest
SHA256 28b5056f015f5c3b79323fdb5cd7cbb6ac2f9b9904833dc518ce0058c4ec8750
MD5 1f5f60efd8775a6d99fb94df1a276e28
BLAKE2b-256 bc88e8ac41069f46c9ee9e2058c48a766b692ba8b584043f5942fe89111d295d

See more details on using hashes here.

File details

Details for the file obsbase-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: obsbase-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for obsbase-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a931fed3980263abd745fa0760f7a7167c4c2ccfe591ec8d3a69adc9b7e56b66
MD5 503f292a55bf9604f65ee1b6e373409f
BLAKE2b-256 de3a2276a58213ec3662ea56115a2a5ad8e72f36b97f8c16883ffca30fbcdca3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page