Created
February 20, 2019 03:47
-
-
Save gartnera/286c20d96c81d90ff577e205a5de7e68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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