Look at the following example. Goal is to have to columns which all values of AD and AA as varnames and the corresponding values in each columns.... The file has to be filtered because there are much more different key-values pairs (not only AX:aa).
\documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{datatool}
\usepackage{filecontents}
\begin{filecontents*}{c.csv}
AA:BB
AX:sdsd
AX:sdsd
AX:sdsd
AX:sdsd
AX:sdsd
AD:CC
AY:asas
AY:asas
AY:asas
AY:asas
AY:asas
AY:asas
AA:BB
AX:sdsd
AX:sdsd
AX:sdsd
AX:sdsd
AX:sdsd
AD:CC
AY:asas
AY:asas
AY:asas
AY:asas
AY:asas
AY:asas
\end{filecontents*}
\begin{document}
\DTLnewdb{tbase}
\DTLnewrow{tbase}
\DTLsetseparator{:}
\DTLloaddb[keys={ca,cb}]{dbn}{c.csv}
\section{A}
\DTLforeach[\DTLiseq{\ca}{AA}\OR\DTLiseq{\ca}{AD}]{dbn}{\ca=ca, \cb=cb}{
\DTLifoddrow{%
\DTLcurrentindex \ \protect\ca \ \protect\cb%
\DTLnewdbentry{tbase}{\ca}{\cb}%
}%
{%
\protect\ca \ \protect\cb\\%
\DTLnewdbentry{tbase}{\ca}{\cb}%
\DTLnewrow{tbase}%
}%
}%
\section{B}
\DTLdisplaydb{tbase}
\end{document}
I am sure its a simple mistake ...;(