HowTo support arbitrary CSV formats

#bankstatement #howto

Using the example of the new csv format file csv-standard-bank-na.def I would like to explain – hopefully comprehensible – how to support more or less arbitrary csv formats. Take just one of the existing files and adjust them accordingly!

  1. First one determines the order of the keys in the csv file.
  2. Then we define \STM@JK@DTLforeach ; a macro that reads the csv file line by line and outputs them as LaTeX table row. It uses to the \DTLforeach macro (datatool.sty)

    • As the first argument you pass the name of the csv file. No change!
    • The second argument maps the csv keys to macros
    • In the third and final argument, the output of the three-column table row is done
      • In the first column we output the posting and value dates
      • In the second column we output the reference, which may be composed of several csv keys.
      • In the third column we output the value. A negative amount will be typeset in red (negativcolor option)
      • Finally, a test on the last row of data is performed and the closing balance or a blank line is issued.
  3. In the last step, we define the separator of the csv file and determine whether it has a header row (Caution: header → noheader=false! (noheader option (datatool.sty))). The last line can be usually simply copied (siunitx setup)!

Hopefully this helps to adapt and support other csv formats! 😉

Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someonePrint this page

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.