[Tex/LaTex] Cannot import csv file data to table in latex using csvsimple

csvcsvsimple

I don't know why the data rows not shows up. Only the header, here is my csv file:

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

And my MWE:

\begin{document}
\usepackage{csvsimple}
\usepackage{datatool}  
\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 \\
        \csvreader[head to column names]{csv/dropped-conn/error-socket.csv}{}%
        {\\\hline\error & \occurences}%
        \\\hline
    \end{tabular}
\end{table}
\end{document}

Best Answer

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}

enter image description here