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.3.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.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: obsbase-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 48176e73d01255a6d47f1cbf5fabe31105c7da31a8bbbd81106ed39f9790afc4
MD5 eb9b2060d9aae4cc8480f3aab38da066
BLAKE2b-256 26aa2409da3d4648f29a83652d5784034c205d304da8ddd4fd21f12c437c7f0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: obsbase-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 78c21b943bf5eb42340541a25a282d4d74ae2f84699bef616b6dab653057a154
MD5 b830571de984ab45cdb0b622a7b43f78
BLAKE2b-256 c3e6a0c6a32251f113cf0c0f92c8917372a8934d76b4cbee1acda50fe64324bc

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