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.1.tar.gz (7.8 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.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: obsbase-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 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.1.tar.gz
Algorithm Hash digest
SHA256 a914b9d31e7d6892659e0e08f490fcc46f10568d1b1b96c1ca6ece8a3d1e0f31
MD5 3cc7b7d7a6b5797ae86b294a1073fe09
BLAKE2b-256 22910601dbb1546f6da6ef93babeab1cc41023a4d9ce202ea10b1f0548ffdea2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: obsbase-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1b7b9f3646514c01c69931c259a4c178e9d5ed8ca177dd41e4570119faa0b8d
MD5 05016afb548dcea85046feb696c8bb69
BLAKE2b-256 e118283618470e1b5f4fc2dda8708fc85e00c7cbf2012c2cc5cbb908c39126d9

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