The per-item testing should be performed when setting the item, rather than in the header, since the filter are set globally. From the csvsimple
documentation:
\csvfilterreject
All following data lines will be ignored. This command overwrites all previous filter settings.
![enter image description here](https://i.stack.imgur.com/pyUTD.png)
\documentclass{article}
\usepackage{csvsimple,filecontents}% http://ctan.org/pkg/{csvsimple,filecontents}
\begin{document}
\begin{filecontents*}{chunk.csv}
AAAA,aaaaa
BBBB,bbbbb
CCCC,ccccc
DDDD,ddddd
EEEE,eeeee
FFFFF,fffffff
GGGGG,ggggg
HHHHHH,hhhhh
\end{filecontents*}
\begin{itemize}
\csvreader[no head]{chunk.csv}{}{\ifnum\value{csvrow}<4\relax\item \csvcoli, \csvcolii\fi}
\end{itemize}
\hrulefill
\begin{itemize}
\csvreader[no head]{chunk.csv}{}{\ifnum\value{csvrow}=4\relax\item \csvcoli, \csvcolii\fi}
\end{itemize}
\hrulefill
\begin{itemize}
\csvreader[no head]{chunk.csv}{}{\ifnum\value{csvrow}>4\relax\item \csvcoli, \csvcolii\fi}
\end{itemize}
\end{document}
Low-level conditionals are used to (not) print each item, testing the value of csvrow
.
Here is an alternative option using datatool
. The interface is very similar, and the transition should therefore not be a problem:
![enter image description here](https://i.stack.imgur.com/aw1vD.png)
\documentclass{article}
\usepackage{datatool,filecontents}% http://ctan.org/pkg/{datatool,filecontents}
\begin{document}
\begin{filecontents*}{chunk.csv}
AAAA,aaaaa
BBBB,bbbbb
CCCC,ccccc
DDDD,ddddd
EEEE,eeeee
FFFFF,fffffff
GGGGG,ggggg
HHHHHH,hhhhh
\end{filecontents*}
\DTLloaddb[noheader,keys={first,last}]{chunk}{chunk.csv}
\begin{itemize}
\DTLforeach{chunk}{\First=first,\Last=last}{\ifnum\value{DTLrowi}<4\relax\item \First, \Last\fi}
\end{itemize}
\hrulefill
\begin{itemize}
\DTLforeach{chunk}{\First=first,\Last=last}{\ifnum\value{DTLrowi}=4\relax\item \First, \Last\fi}
\end{itemize}
\hrulefill
\begin{itemize}
\DTLforeach{chunk}{\First=first,\Last=last}{\ifnum\value{DTLrowi}>4\relax\item \First, \Last\fi}
\end{itemize}
\end{document}
Low-level conditionals are used to (not) print each item, testing the value of DTLrowi
.
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](https://i.stack.imgur.com/hh7BF.png)
Best Answer
You can't use
\meaning
because it's a reserved command to print out a macros command, for example\meaning\csvreader
.I just can recommend you to always use individual prefixes for your macros.
MWE: