Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{filecontents}
  3. usepackage{datatool}
  4.  
  5. begin{filecontents*}{A.csv}
  6. date,colA
  7. 2016-01-01,1
  8. 2016-01-02,4
  9. 2016-01-03,2
  10. end{filecontents*}
  11.  
  12. begin{filecontents*}{B.csv}
  13. date,colB0,colB1,colB2,colB3
  14. 2016-01-01,2,b10,b11,b12
  15. 2016-01-03,4,b20,b21,b22
  16. end{filecontents*}
  17.  
  18. begin{filecontents*}{D.csv}
  19. date,colD0,colD1,colD2,colD3
  20. 2016-01-01,2,d10,d11,d12
  21. 2016-01-03,4,d20,d21,d22
  22. end{filecontents*}
  23.  
  24.  
  25. % DTLloaddb{A}{A.csv}
  26. DTLloaddb{B}{B.csv}
  27. DTLloaddb{D}{D.csv}
  28. DTLloaddb{E}{A.csv}
  29.  
  30. DTLforeach{E}{Date=date}{
  31. DTLgetvalueforkey{tmp}{colB0}{B}{date}{Date}
  32. %DTLgetvalueforkey{tmp}{colB1}{B}{date}{Date}
  33. DTLappendtorow{colB0}{DTLifnull{tmp}{0}{tmp}}
  34. }
  35.  
  36. begin{document}
  37.  
  38. DTLsetseparator{,}
  39. DTLsetdelimiter{"}
  40. DTLsavedb{E}{E.csv} % doesn't write if before begin{document}
  41.  
  42. DTLdisplaydb{E}
  43.  
  44. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement