1
0

Remove mapped fields

This commit is contained in:
Jon Michael Aanes 2024-10-03 23:32:30 +02:00
parent 3f0ab40982
commit 6b606475df
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 8 additions and 4 deletions

View File

@ -32,10 +32,12 @@ def import_data(obsidian_path: Path, dry_run=True):
for input_key, (output_key, unit) in mapping.items():
v = row.get(input_key)
if unit:
v = str(v) + ' ' + unit
if v:
was_updated |= vault.add_statistic(date, output_key, v)
if v is not None:
if unit:
v = str(v) + ' ' + unit
was_updated |= vault.add_statistic(date, output_key, v)
if input_key != output_key:
was_updated |= vault.add_statistic(date, input_key, None)
del input_key, output_key, unit, v
if was_updated:

View File

@ -59,6 +59,8 @@ class ObsidianVault:
return False
data.metadata[statistic_key] = amount
if amount is None:
del data.metadata[statistic_key]
with open(self._date_file_path(date), 'wb') as f:
frontmatter.dump(data, f)