CSV to Latex
Some banking apps have a feature whereby monthly statements can be downloaded in csv format. (Comma separated variables). I wrote a Julia program to convert such a statement to a latex document. This document can then be converted to a pdf file using a command line utility called pdflatex. (Alternatively it could be loaded into TeXstudio and then turned to a pdf file).
The code is called StarlingStatementV5.jl. It uses the first command line argument as the .csv file to be read. The second command line argument as the output .tex file to be created. Then pdflatex is used to create the pdf file.
Latex
Latex is used to set out the text and figures in two tables. The use of the tabularray environment for the first table is used because the table breaks across page breaks really well. This is bound to happen given a months worth of transactions.
I got an error using this package:
"LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right."
Rerunning the pdflatex program fixes the problem.
Looking on the web, this seems to be quite a common problem and a common fix for the problem.
I had previously looked into having page numbers of the form 'Page x of y' and abandoned it because it needed two compiles. It seems like I should just get used to doing this so maybe I will also incorporate the page numbering code!
The page is orientated in landscape and the the line-spacing is adjusted to 1.5 for clarity and ease of use.
The Summary Table
It was easy to add a note at the end of the statement giving:
- Opening Balance
- Total negative numbers
- Total positive numbers
- Expenditure (3rd item - 2nd item)
- Final Balance
This clearly identifies the opening and closing balances and can be used to check on our own calculations. The opening balance is calculated by reversing the first transaction because the csv file does not include an opening balance. The closing balance printed on the page is the last balance in the csv file, i.e. the one after the last transaction. There is code to add up all the positive numbers and almost identical code to add up all the negative numbers. Then the Expenditure number is calculated: (sum of positives) - (sum of negatives). There is some code to check that the opening balance plus the expenditure gives the closing balance from the csv file. A message to this effect is printed when it is correct, an error message is printed if it is not.
Final Notes
There is quite a lot of escaping in the Latex strings. I thought it might be possible to eliminate the escaping by using the package LaTeXStrings. Having 'using LaTeXStrings' at the top of the code should mean that the Latex can be coded up by using the syntax L"\documentclass[12pt]{article}". However, for some reason some stray dollar signs are sprinkled around the output tex and cause it to fail. It seemed easier to just escape special characters than try to fix this so the LaTexStrings package is not used.