0

I'm trying to import my data from a .csv file into a table in LaTeX using csvsimple\csvautotabular. My .csv looks as follows

Inter-Studie;;;;;;;;;;;;  
;P1;;P2;;P3;;P4;;mean (lat);std (lat);mean (med);std (med)  
;lat;med;lat;med;lat;med;lat;med;;;;  
O1 - O2;0,858;0,768;0,841;0,816;0,803;0,799;0,790,0,811;0,823;0,0276;0,798;0,0188  
O1 - O3;0,859;0,789;0,877;0,885;0,852;0,848;0,870,0,857;0,864;0,0096;0,845;0,0348  
O1 - O4;0,779;0,479;0,863;0,793;0,879;0,827;0,829;0,668;0,838;0,0381;0,692;0,1364  
O2 - O3;0,847;0,819;0,861;0,852;0,844;0,815;0,833;0,842;0,846;0,0102;0,832;0,0156  
O2 - O4;0,732;0,521;0,809;0,767;0,804;0,812;0,785;0,686;0,782;0,0307;0,697;0,1110  
O3 - O4;0,747;0,478;0,884;0,783;0,849;0,860,0,794;0,653;0,818;0,0525;0,694;0,1449  
Mean;0,804;0,642;0,856;0,816;0,838;0,827;0,817;0,753;0,829;0,0000,0,760,0,0000  
Std;0,058;0,165;0,027;0,045;0,030,0,023;0,033;0,093;0,037;0,0000,0,082;0,0000  
Min;0,732;0,478;0,809;0,767;0,803;0,799;0,785;0,653;0,782;0,0000,0,674;0,0000  
Max;0,859;0,819;0,884;0,885;0,879;0,860,0,870,0,857;0,873;0,0000,0,855;0,0000  

Using the following code

    \NeedsTeXFormat{LaTeX2e}
    \documentclass[a4paper,12pt,
    headsepline,           % Linie zw. Kopfzeile und Text
    oneside,               % einseitig
    pointlessnumbers,      % keine Punkte nach den letzten Ziffern in Überschriften
    bibtotoc,              % LV im IV
    %DIV=15,               % Satzspiegel auf 15er Raster, schmalere Ränder   
    BCOR=15mm              % Bindekorrektur
    %,draft
    ]{scrbook}
    \KOMAoptions{DIV=last} % Neuberechnung Satzspiegel nach Laden von Paket helvet

    \pagestyle{headings}
    \usepackage{blindtext}

    % texts in german language
    \usepackage[ngerman]{babel}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}

    % Helvetica as writing
    \usepackage[scaled]{helvet}
    \renewcommand{\familydefault}{\sfdefault} 

    \usepackage{graphicx}
    % to import  csv files
    \usepackage{csvsimple}
    \usepackage{longtable}

    %to rotate tables
    \usepackage{adjustbox}
    \usepackage[graphicx]{realboxes}
    \usepackage{rotating}

    \begin{document}
        \begin{sidewaystable} 
            \csvautotabular[separator=semicolon]{csvtable.csv}
        \end{sidewaystable}
    \end{document}

I get as a result:

enter image description here

Disregarding the fact that the positioning of my table puts it over the header of my document, I don't know how to get rid of the " that csvautotabular puts at the beginning and end of every line in my table. Neither do I understand why csvautotabular is ignoring some lines from my .csv file and others it doesn't ignore. And a last question is, why there are these '/.@cmd' and '/.@body'appearing in my document?

3
  • please give us a copyable code for your csv file. With an iage we can not test, sorry. BTW: Welcome to TeX.SE!
    – Mensch
    Commented Feb 17, 2022 at 17:03
  • as well as the csv file please fix the tex fragment so that it is a minimal but complete document that reproduces the problem. Commented Feb 17, 2022 at 17:12
  • I think the way I updated the post it should be fine? Commented Feb 17, 2022 at 17:48

1 Answer 1

1

You table will be fine if you correct csvtable.csv

(Some , for ;}

d

Try this file:

Inter-Studie;;;;;;;;;;;;
;P1;;P2;;P3;;P4;;mean (lat);std (lat);mean (med);std (med)
;lat;med;lat;med;lat;med;lat;med;;;;
O1 - O2;0,858;0,768;0,841;0,816;0,803;0,799;0,790;0,811;0,823;0,0276;0,798;0,0188
O1 - O3;0,859;0,789;0,877;0,885;0,852;0,848;0,870;0,857;0,864;0,0096;0,845;0,0348
O1 - O4;0,779;0,479;0,863;0,793;0,879;0,827;0,829;0,668;0,838;0,0381;0,692;0,1364
O2 - O3;0,847;0,819;0,861;0,852;0,844;0,815;0,833;0,842;0,846;0,0102;0,832;0,0156
O2 - O4;0,732;0,521;0,809;0,767;0,804;0,812;0,785;0,686;0,782;0,0307;0,697;0,1110
O3 - O4;0,747;0,478;0,884;0,783;0,849;0,860;0,794;0,653;0,818;0,0525;0,694;0,1449
Mean;0,804;0,642;0,856;0,816;0,838;0,827;0,817;0,753;0,829;0,0000;0,760;0,0000
Std;0,058;0,165;0,027;0,045;0,030;0,023;0,033;0,093;0,037;0,0000;0,082;0,0000
Min;0,732;0,478;0,809;0,767;0,803;0,799;0,785;0,653;0,782;0,0000;0,674;0,0000
Max;0,859;0,819;0,884;0,885;0,879;0,860;0,870;0,857;0,873;0,0000;0,855;0,0000

Loading the .csv file in excel makes it easy to pinpoint the problems.

Original

c

Corrected

b

This is the complete code.

\documentclass[a4paper,12pt,
headsepline,           % Linie zw. Kopfzeile und Text
oneside,               % einseitig
pointlessnumbers,      % keine Punkte nach den letzten Ziffern in Überschriften
bibtotoc,              % LV im IV
%DIV=15,               % Satzspiegel auf 15er Raster, schmalere Ränder   
BCOR=15mm              % Bindekorrektur
%,draft
]{scrbook}
\KOMAoptions{DIV=last} % Neuberechnung Satzspiegel nach Laden von Paket helvet

\pagestyle{headings}
\usepackage{blindtext}

% texts in german language
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% Helvetica as writing
\usepackage[scaled]{helvet}
\renewcommand{\familydefault}{\sfdefault} 

\usepackage{graphicx}
% to import  csv files
\usepackage{csvsimple}
\usepackage{longtable}

%to rotate tables
\usepackage{adjustbox}
\usepackage[graphicx]{realboxes}
\usepackage{rotating}

\begin{filecontents*}[overwrite]{csvtable.csv}
Inter-Studie;     ;     ;     ;     ;     ;     ;     ;     ;          ;         ;          ;
            ;P1   ;     ;P2   ;     ;P3   ;     ;P4   ;     ;mean (lat);std (lat);mean (med);std (med)
            ;lat  ;med  ;lat  ;med  ;lat  ;med  ;lat  ;med  ;          ;         ;          ;
O1 - O2     ;0,858;0,768;0,841;0,816;0,803;0,799;0,790;0,811;0,823     ;0,0276   ;0,798     ;0,0188
O1 - O3     ;0,859;0,789;0,877;0,885;0,852;0,848;0,870;0,857;0,864     ;0,0096   ;0,845     ;0,0348
O1 - O4     ;0,779;0,479;0,863;0,793;0,879;0,827;0,829;0,668;0,838     ;0,0381   ;0,692     ;0,1364
O2 - O3     ;0,847;0,819;0,861;0,852;0,844;0,815;0,833;0,842;0,846     ;0,0102   ;0,832     ;0,0156
O2 - O4     ;0,732;0,521;0,809;0,767;0,804;0,812;0,785;0,686;0,782     ;0,0307   ;0,697     ;0,1110
O3 - O4     ;0,747;0,478;0,884;0,783;0,849;0,860;0,794;0,653;0,818     ;0,0525   ;0,694     ;0,1449
Mean        ;0,804;0,642;0,856;0,816;0,838;0,827;0,817;0,753;0,829     ;0,0000   ;0,760     ;0,0000
Std         ;0,058;0,165;0,027;0,045;0,030;0,023;0,033;0,093;0,037     ;0,0000   ;0,082     ;0,0000
Min         ;0,732;0,478;0,809;0,767;0,803;0,799;0,785;0,653;0,782     ;0,0000   ;0,674     ;0,0000
Max         ;0,859;0,819;0,884;0,885;0,879;0,860;0,870;0,857;0,873     ;0,0000   ;0,855     ;0,0000
\end{filecontents*}
    
\begin{document}
\begin{sidewaystable} 
\csvautotabular[separator=semicolon]{csvtable.csv}
    \end{sidewaystable}
\end{document}
4
  • Well in your table there are still some lines missing like the one starting with O1 - O2 for example Commented Feb 17, 2022 at 19:34
  • @Christophe Andre I uploaded the wrong figure :). Please test the new .csv file. Your code runs fine. Commented Feb 17, 2022 at 19:41
  • Using the manual filecontents in my latex code, it works. Thank you! Commented Feb 18, 2022 at 8:23
  • @Christophe Andre Then you may accept this answer by clicking the check mark in the top left corner. Commented Feb 21, 2022 at 14:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .