2

I'm not sure if the title describes the question clearly.

I have a latex document that uses the csvsimple package to read some columns from a large datafile and make a nice table. It works fine, but now I want to submit the paper to a journal which won't let me use that package :-(

I was wondering if there was a way of getting the processed table and inserting it in a document that doesn't use the package, i.e. analogous to the situation when you are not allowed to use bibtex, then you can cut and paste the bbl file that bibtex generates in the document instead.

  • 1
    pgfplotstable allows to create a file with your table formatted like TeX (with & and \\ separators), then you could \input these files in your documents... – CarLaTeX May 26 '18 at 11:01
  • interesting, can it let me pick out column entries from a large CSV file as csvsimple can? – Adrian Tompkins May 26 '18 at 11:17
  • 1
    I think you can, please add a MWE with fake data – CarLaTeX May 26 '18 at 11:19
  • 3
    You could make a standalone pdf-picture and insert it with \includegraphics. – Ulrike Fischer May 26 '18 at 12:28
  • Any reason for not accepting csvsimple? – Ignasi May 28 '18 at 6:34
1

For little tables, the method suggested by Ulrike is the more convenient: make a standalone document with your table and insert the output .pdf with \includegraphics.

For long tables, maybe the following method can help (of course, you can also apply it to short tables, if you like).

Since you didn't provide an MWE, I completely invented the table, you will have to adapt it to your needs.

With the option outfile={...}, pgfplotstable package allows to create a table code starting from a .csv. For example, the following code creates mytable.tex:

\documentclass{article}
\usepackage{pgfplotstable} 
\usepackage{array}
\usepackage{siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.4}
\newcolumntype{U}{S[table-format=7, table-column-width=4em]}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{caption}
\captionsetup{labelfont=bf, textfont=bf, labelsep=endash, 
    justification=centering}
\usepackage{filecontents}
\begin{filecontents*}{mydata.csv}
    number,description
    12342,I have used \texttt{siunitx} for the first column and centered the second column only to show the various possibilities
    2345365,{Of course, you have to set the columns according to your needs}
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text    
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text    
    12342,Some text
    2345365,Some text
    557484,Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text    
\end{filecontents*}

\begin{document}
    \pgfplotstabletypeset[
        begin table=\begin{longtable},
        end table=\end{longtable},
        outfile={mytable.tex}, % table code
        col sep=comma,
        string type,
        columns/number/.style={
            column name={\multicolumn{1}{U}{\textbf{No}}}, 
            column type={U}
        },
        columns/description/.style={
            column name={\textbf{Description}}, 
            column type={C{.7\textwidth}}
        },
        every head row/.style={before row=\midrule, after row=\midrule},
        %every last row/.style={after row=\midrule},
        every head row/.append style={before row={% 
                \caption{My caption}\label{tab:mylab}\\
                \toprule
                \endfirsthead
                \multicolumn{2}{l}{{\dots continued from previous page}}\\
                \toprule
                \multicolumn{1}{U}{\textbf{No}} & \multicolumn{1}{C{.7\textwidth}}{\textbf{Description}} \\ 
                \midrule
                \endhead
                \midrule
                \multicolumn{2}{r}{{\dots continued on next page}} \\ 
                \endfoot %
                \bottomrule 
                \endlastfoot % 
            }
        }
        ]{mydata.csv}

\end{document}

Here is mytable.tex:

\begin {longtable}{UC{.7\textwidth }}%
\caption {My caption}\label {tab:mylab}\\ \toprule \endfirsthead \multicolumn {2}{l}{{\dots continued from previous page}}\\ \toprule \multicolumn {1}{U}{\textbf {No}} & \multicolumn {1}{C{.7\textwidth }}{\textbf {Description}} \\ \midrule \endhead \midrule \multicolumn {2}{r}{{\dots continued on next page}} \\ \endfoot \bottomrule \endlastfoot \multicolumn {1}{U}{\textbf {No}}&\textbf {Description}\\\midrule %
12342&I have used \texttt {siunitx} for the first column and centered the second column only to show the various possibilities\\%
2345365&Of course, you have to set the columns according to your needs\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
12342&Some text\\%
2345365&Some text\\%
557484&Some long long long long long long long long long long long long long long long long long long long long long long long long long long long long text\\%
\end {longtable}%

Now you can input mytable.tex in your main document:

\documentclass{article}
\usepackage{array}
\usepackage{siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.4}
\newcolumntype{U}{S[table-format=7, table-column-width=4em]}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{caption}
\captionsetup{labelfont=bf, textfont=bf, labelsep=endash, 
    justification=centering}
\begin{document}
    \input{mytable.tex}
\end{document}

The result is:

enter image description here enter image description here

1

If the problem is that you cannot submit your paper with an auxiliary file containing data, you can use filecontents package to join both files in one.

You can submit something only one file similar to:

\documentclass{article}
\usepackage{filecontents}
\usepackage{csvsimple}
\usepackage{booktabs}
\usepackage{lmodern}

\begin{filecontents*}{mydata.csv}
land,group,amount
Bayern,A,1700
Baden-Württemberg,A,2300
Sachsen,B,1520
Thüringen,A,1900
Hessen,B,2100
\end{filecontents*}

\begin{document}
This is your paper contents.
\csvautobooktabular{mydata.csv}
\end{document}

Data are included on preamble inside a filecontents environment. It means that when your document is processed, a new file mydata.csv will be automatically created with your cvs data and later on processed with csvsimple commands.

enter image description here

Note: Data and command taken from csvsimple documentation.

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.