Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /*
  2. Make sure your csv has these headers:
  3. description,dateAcquired,dateSold,salesPrice,cost
  4.  
  5. Convert csv to json.
  6.  
  7. Paste the following code into the console.
  8.  
  9. Run fillAll with the json as an argument.
  10. */
  11.  
  12. function fill(n, obj){
  13. const baseSel = `capitalGains[${n}]`
  14. for (const key in obj) {
  15. const sel = `${baseSel}.${key}`;
  16. const el = document.getElementsByName(sel)[0];
  17. el.value = obj[key];
  18. }
  19. }
  20.  
  21. function fillAll(objs) {
  22. for (const [i, obj] of objs.entries()) {
  23. fill(i, obj);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement