1

I'm trying to import a .csv while using longtable and pdfplotstabletypeset. I can't get the longtable command to work.

\documentclass[12pt,a4paper,oneside]{report}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{pgfplotstable}
\usepackage{ragged2e}
\usepackage{pdfpages}
\usepackage{pdflscape}
\usepackage{tikz}
\usepackage{subcaption}

\begin{filecontents*}{MYFILE.csv}
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
\end{filecontents*}

\begin{document}

\begin{table}[!htb]
%   \setstretch{1.1}
    \pgfplotstabletypeset[
        column type=,
        col sep=comma, 
        string type,
        begin table={\begin{longtable}{p{5cm}p{10cm}}},
%       begin table={\begin{longtable}{@{*}r||p{1in}@{*}},
            end table={\end{longtable}},
        every head row/.style={
            before row={\toprule},
            after row={\midrule\addlinespace}},
        assign column name/.style={/pgfplots/table/column name={\textbf{#1}}},
        every last row/.style={after row=\midrule},
        every row no 5/.style={after row=\toprule\addlinespace},
        every row no 6/.style={after row=\midrule\addlinespace},
        every row 6 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
        every row no 14/.style={after row=\toprule\addlinespace},
        every row no 15/.style={after row=\midrule\addlinespace},
        every row 15 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
        every row no 18/.style={after row=\toprule\addlinespace},
        every row no 19/.style={after row=\midrule\addlinespace},
        every row 19 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
        every row no 22/.style={after row=\toprule\addlinespace},
        every row no 23/.style={after row=\midrule\addlinespace},
        every row 23 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
        every row no 26/.style={after row=\toprule\addlinespace},
        every row no 27/.style={after row=\midrule\addlinespace},
        every row 27 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
    ]{MYFILE.csv}
\end{table}

\end{document}
0

A table environment cannot break across pages, longtable is meant to be used outside of tables. Hence, remove \begin{table} and \end{table}. If you want a caption on the top of the table, do e.g. every head row/.style={before row={\caption{foo}\\\toprule}, ...

1
  • Thanks, I'll post the code below for others... – SP1 Oct 15 '20 at 7:38
0

Here's the code that worked for me:

\pgfplotstabletypeset[
    column type=,
    col sep=comma, 
    string type,
    begin table={\begin{longtable}{p{5cm}p{10cm}}},
        end table={\end{longtable}},
    every head row/.style={
        before row={\toprule},
        after row={\midrule\addlinespace}},
    assign column name/.style={/pgfplots/table/column name={\textbf{#1}}},
    every last row/.style={after row=\midrule},
    every row no 5/.style={after row=\toprule\addlinespace},
    every row no 6/.style={after row=\midrule\addlinespace},
    every row 6 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
    every row no 14/.style={after row=\toprule\addlinespace},
    every row no 15/.style={after row=\midrule\addlinespace},
    every row 15 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
    every row no 18/.style={after row=\toprule\addlinespace},
    every row no 19/.style={after row=\midrule\addlinespace},
    every row 19 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}}
    ]{MYFILE.csv}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.