I'm trying to recreate a wholesale price list in LaTeX so that the data can be updated automatically from CSV files.
I'm able to import data using \csvautolongtable
but I'm struggling with the formatting. This will be shown to customers as well as used internally so I would like it to look at least as good as the Excel tables the data originally came from (below):
My questions are as follows:
-
Is there a way to recreate a table with similar (ideally better) formatting using csvsimple? Particularly the wrapping of long lines, prices in bold and center-aligned headers.
Wrapping is especially important because otherwise I need to set the font to a tiny size or the table doesn't fit on the page. I'm using longtable because some other data fills more than one page.
-
Prices are in GBP, how do I get csvsimple to read the £ symbols in the CSV files? It's currently ignoring them.
Here is the CSV (technically semi-colon separated) file I'm working with:
\begin{filecontents*}{olive_oil_data.csv}
Code;Product Name;Unit Size;Pack Size;Unit Price
1463;AGULLO OLIVE OIL (Valencia , good value and fruity using Picual, Arbequina, Cornicabra and Chancló olives) ;5 litre;3;£17.00
1489;CAL MAS EXTRA VIRGEN OIL (Valencia, artisan single estate using Blanqueta and Alfafara olives );750ml;12;£8.52
3001;GOMEOLIVA OLIVE OIL (Andalucia, smooth and fruity using Hojiblanca and Picual olives);5 litre;3;£20.25
3002;GOMEOLIVA OLIVE OIL (Andalucia, smooth and fruity using Hojiblanca and Picual olives);2 litre;6;£8.33
3003;GOMEOLIVA OLIVE OIL (Andalucia, smooth and fruity using Hojiblanca and Picual olives );1 litre;15;£4.13
3008;MAIMONA OLIVE OIL GLASS (Extramadura, intense green colour using Morisca olives);750ml;12;£3.86
3004;MAIMONA OLIVE OIL TIN (Extramadura, intense green colour using Morisca olives);5 litre;4;£23.91
3016;MAS D'EN GIL OLIVE OIL (Priorat, artisan delicate taste using Arberquina olives );500ml;6;£8.57
3011;MOLINO OLIVE OILGLASS (Andalucia, unfiltered fruity using Hojiblanca and Picual olives );750ml;6;£4.85
3009;MOLINO OLIVE OIL TIN (Andalucia unfiltered fruity, Hojiblanca Picual olives);5 litre;3;£22.10
3019;ORGANIC OLIVE OIL (Andalucia, organic using Hojiblanca and Picual olives );5 litre;3;£26.93
3020;ORGANIC OLIVE OIL (Andalucia , organic using Hojiblanca and Picual olives);2 litre;6;£11.03
1331;CAPIRETE PICUAL OLIVE OIL (Jaen, single estate high expression oil);500ml;12;£5.77
3021;ORGANIC OLIVE OIL GLASS (Andalucia, Andalucia, organic using Hojiblanca and Picual olives );1 litre;12;£6.21
\end{filecontents*}
I know it's good practice to provide a MWE, so far all I have is this:
\documentclass[a4paper,11pt]{article}
\usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{longtable}
\usepackage{csvsimple}
\begin{document}
\section*{Olive Oil}
\csvautolongtable[
before reading=\footnotesize,
late after line=\\\hline,
late after last line=,
after reading=\normalsize,
separator=semicolon,
respect and=true]
{./olive_oil_data.csv}
\end{longtable}
\end{document}
Thank you for your help.
Best Answer
For the pounds symbol, there has to be some file encoding chosen. If you are in the Windows world, you may have cp1252 encoded files (?).
In my answer, I assume this encoding and use
latin1
oninputenc
. If you use UTF-8, this setting has to be changed.The following code tries to rebuild your screenshot (but in black and white so far).
Using the
booktabs
package gives maybe some more pleasing results. See the following example code: