Skip to content

Instantly share code, notes, and snippets.

@gartnera
Created February 20, 2019 03:47
Show Gist options
  • Save gartnera/286c20d96c81d90ff577e205a5de7e68 to your computer and use it in GitHub Desktop.
Save gartnera/286c20d96c81d90ff577e205a5de7e68 to your computer and use it in GitHub Desktop.
/*
Make sure your csv has these headers:
description,dateAcquired,dateSold,salesPrice,cost
Convert csv to json.
Paste the following code into the console.
Run fillAll with the json as an argument.
*/
function fill(n, obj){
const baseSel = `capitalGains[${n}]`
for (const key in obj) {
const sel = `${baseSel}.${key}`;
const el = document.getElementsByName(sel)[0];
el.value = obj[key];
}
}
function fillAll(objs) {
for (const [i, obj] of objs.entries()) {
fill(i, obj);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment