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
on inputenc
.
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).
\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*}
\documentclass[a4paper,11pt]{article}
% Encoding (e.g. Windows Cp1252)
% Has to be changed for UFT-8, if used
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{longtable,array}
\usepackage{csvsimple}
\usepackage{lmodern}% could be left out or chanaged to another font
\newcommand*{\headentry}[2]{\multicolumn{1}{#1}{\centering\arraybackslash\bfseries #2}}
\begin{document}
\section*{Olive Oil}
\csvreader[
separator=semicolon,
before table=\sffamily\small,
longtable={|r|p{10cm}|r|r|r|},
table head={\hline%
\headentry{|m{1.8cm}|}{PRODUCT\linebreak CODE}
& \headentry{m{10cm}|}{PRODUCT NAME}
& \headentry{m{1cm}|}{UNIT\linebreak SIZE}
& \headentry{m{1cm}|}{PACK\linebreak SIZE}
& \headentry{m{2.2cm}|}{WHOLESALE\linebreak UNIT PRICE}\\\hline},
late after line=\\\hline,
]
{./olive_oil_data.csv}
{Code=\code,Product Name=\name,Unit Size=\unitsize,Pack Size=\packsize,Unit Price=\unitprice}
{\code & \name & \unitsize & \packsize & \unitprice}
\end{document}
Using the booktabs
package gives maybe some more pleasing results. See the following example code:
\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*}
\documentclass[a4paper,11pt]{article}
% Encoding (e.g. Windows Cp1252)
% Has to be changed for UFT-8, if used
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{longtable,array,booktabs,xcolor}
\usepackage{csvsimple}
\usepackage{lmodern}% could be left out or chanaged to another font
\newcommand*{\headentry}[2]{\multicolumn{1}{m{#1}}{\centering\arraybackslash\textcolor{red!85!black}{\bfseries #2}}}
\begin{document}
\section*{Olive Oil}
\csvreader[
separator=semicolon,
before table=\sffamily\small,
longtable={cp{10cm}rrr},
table head={\toprule%
\headentry{1.8cm}{PRODUCT\linebreak CODE}
& \headentry{10cm}{PRODUCT NAME}
& \headentry{1cm}{UNIT\linebreak SIZE}
& \headentry{1cm}{PACK\linebreak SIZE}
& \headentry{2.2cm}{WHOLESALE\linebreak UNIT PRICE}\\\midrule},
late after line=\\\midrule,
late after last line=\\\bottomrule,
]
{./olive_oil_data.csv}
{Code=\code,Product Name=\name,Unit Size=\unitsize,Pack Size=\packsize,Unit Price=\unitprice}
{\code & \name & \unitsize & \packsize & \bfseries\unitprice}
\end{document}
The problem seems to be the content of your error column. The package seems to not understand the stuff contained in surrounding "
s to be one cell. The result is that it ignores the lines it can't parse, and since this is true for all lines, every line is ignored.
Instead of using "
to denote a cell containing commas, use curly brackets. Also the underscore doesn't work here, you'd have to escape it using \
. The following would work:
CSV:
method,name,error,occurences
socket,socket,{ConnectionResetError(54, 'Connection reset by peer')},12
socket,socket,{CryptoError('Decryption failed. Ciphertext failed verification',)},60
socket,socket,{SSLEOFError(8, 'EOF occurred in violation of protocol (\_ssl.c:748)')},77
socket,socket,{ConnectionRefusedError(61, 'Connection refused')},992
socket,socket,{BrokenPipeError(32, 'Broken pipe')},3
TeX:
\documentclass{article}
\usepackage{csvsimple}
\usepackage{datatool}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\caption[Table~\ref{fig:socketdropconnerr} Error during socket test]{Error during socket test}
\vspace{0.2cm}
\label{fig:drop-error-socket}
\begin{tabular}{ l l }%
\toprule error & occurences \\
\midrule
\csvreader[late after line=\\,head to column
names]{data3.csv}{}%
{\error & \occurences}%
\bottomrule
\end{tabular}
\end{table}
\end{document}
Best Answer
As I have written in my comment, all depends on how to use the data.
csvsimple
has no problem with spaces inside the header as far as you do not create automated macros withhead to column names
.An example usage is the following: