Skip to content

Instantly share code, notes, and snippets.

@harryi3t
Last active January 24, 2022 06:55
Show Gist options
  • Save harryi3t/8c439df8cee752f107824964a0d005fc to your computer and use it in GitHub Desktop.
Save harryi3t/8c439df8cee752f107824964a0d005fc to your computer and use it in GitHub Desktop.
Exports data from wallet web app by budgetbakers
// Wallet is a great app to track your expenses
// I just didn't want to buy premium subscription just to export my own data :shrug:
// First follow this gist to export all the data in indexeddb to console
// https://gist.github.com/harryi3t/d8779d3c0c0c4d41c37fdde81b268fd3
// I will be assuming from here on that the the entire data is in a variable `data`
// All the transactions are store in the table 'by-sequence'
let sequence = data[2]['by-sequence'];
// group all sequences by type of record. eg are 'account', 'category', 'record', 'currency', etc
// similar to _.groupBy(sequence, 'reservedModelType')
let groupedSequence = sequence.reduce((group, item) => {
if (!group[item.reservedModelType])
group[item.reservedModelType] = [];
group[item.reservedModelType].push(item)
return group;
}, {})
// Convert the category array into a map (key is category id and value is category item itself)
groupedSequence.categoryMap = groupedSequence.Category.reduce((group, item) => {
let categoryId = item._doc_id_rev.split('::')[0];
group[categoryId] = item;
return group;
}, {})
// Sort the records by date
groupedSequence.Record = groupedSequence.Record.sort((a, b) => {
return a.reservedCreatedAt.localeCompare(b.reservedCreatedAt)
})
function mapRecordWithCategory (item) {
return {
title: item.note,
date: item.recordDate,
category: groupedSequence.categoryMap[item.categoryId].name,
amount: item.amount/100
}
}
@0x8801
Copy link

0x8801 commented Sep 6, 2019

Thanks for this!

I extended your functions and added account names per transaction and a negative sign for debit amounts

Link here https://gist.github.com/eric-gm/9454490b22b3a5135fbccfe30e1ded08

@harryi3t
Copy link
Author

harryi3t commented Sep 10, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment