I need to insert large tables in the appendix of my MSc thesis and I want to read the data from .csv
files without fill the .tex
file where I write.
I produce the tables with the help of TableGenerator. Let us consider the following cutted .csv
file:
1, 459872 , 2459600.5, 0.245955429393969E+07, 0.150902180397680E+09, 0.700936137135535E-01, 0.444423490130398E+02, 0.509894719093894E+02, 0.449518800380460E+02, 0.972856801473429E+00
2, 1991 VG , 2459600.5, 0.245965301734296E+07, 0.154448562453878E+09, 0.524440272062934E-01, 0.981969077945011E+02, 0.305901193619353E+03, 0.310657729272394E+03, 0.939542405344313E+00
3, 2000 SG344, 2459600.5, 0.245967142235446E+07, 0.146215475380197E+09, 0.668906906224866E-01, 0.107259306095888E+03, 0.280186369328737E+03, 0.287658863754547E+03, 0.102000471918105E+01
4, 2003 YN107, 2459600.5, 0.245973765703815E+07, 0.147913409318582E+09, 0.138963447919681E-01, 0.352070216744272E+03, 0.221439015133514E+03, 0.222501180674322E+03, 0.100249189670507E+01
5, 2006 JY26 , 2459600.5, 0.245950771201134E+07, 0.151137260433216E+09, 0.831296262363333E-01, 0.317110762865456E+03, 0.995403784006208E+02, 0.900588991605521E+02, 0.970587901094867E+00
6, 2006 QQ56 , 2459600.5, 0.245948919576395E+07, 0.147356242165350E+09, 0.455957054639189E-01, 0.132721216278857E+03, 0.116944610798197E+03, 0.112215042556733E+03, 0.100818303543359E+01
My code to produce the table with help of above website is:
\documentclass{article}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{csvsimple}
\usepackage{graphicx}
\sisetup{
round-mode=places,
uncertainty-mode = separate,
}
\begin{table}[]
\centering
\caption{}
\label{tab:my-table}
\resizebox{1.1\textwidth}{!}{%
\begin{tabular}{
c
l
c
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
S[table-format=-1.3e1, round-precision=3, scientific-notation = true]
}
\toprule
\textbf{index} & \multicolumn{1}{c}{\textbf{pdes}} & \textbf{\begin{tabular}[c]{@{}c@{}}epoch \\ (JDTDB)\end{tabular}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}tp\\ (JDTDB)\end{tabular}}} & \multicolumn{1}{c}{\textbf{a\_km}} & \multicolumn{1}{c}{\textbf{e}} & \multicolumn{1}{c}{\textbf{w\_deg}} & \multicolumn{1}{c}{\textbf{ta\_deg}} & \multicolumn{1}{c}{\textbf{ma\_deg}} & \multicolumn{1}{c}{\textbf{n\_deg/d}} \\ \midrule
1 & 459872 & 2459600.5 & 0.245955429393969E+07 & 0.150902180397680E+09 & 0.700936137135535E-01 & 0.444423490130398E+02 & 0.509894719093894E+02 & 0.449518800380460E+02 & 0.972856801473429E+00 \\
2 & 1991 VG & 2459600.5 & 0.245965301734296E+07 & 0.154448562453878E+09 & 0.524440272062934E-01 & 0.981969077945011E+02 & 0.305901193619353E+03 & 0.310657729272394E+03 & 0.939542405344313E+00 \\
3 & 2000 SG344 & 2459600.5 & 0.245967142235446E+07 & 0.146215475380197E+09 & 0.668906906224866E-01 & 0.107259306095888E+03 & 0.280186369328737E+03 & 0.287658863754547E+03 & 0.102000471918105E+01 \\
4 & 2003 YN107 & 2459600.5 & 0.245973765703815E+07 & 0.147913409318582E+09 & 0.138963447919681E-01 & 0.352070216744272E+03 & 0.221439015133514E+03 & 0.222501180674322E+03 & 0.100249189670507E+01 \\
5 & 2006 JY26 & 2459600.5 & 0.245950771201134E+07 & 0.151137260433216E+09 & 0.831296262363333E-01 & 0.317110762865456E+03 & 0.995403784006208E+02 & 0.900588991605521E+02 & 0.970587901094867E+00 \\
6 & 2006 QQ56 & 2459600.5 & 0.245948919576395E+07 & 0.147356242165350E+09 & 0.455957054639189E-01 & 0.132721216278857E+03 & 0.116944610798197E+03 & 0.112215042556733E+03 & 0.100818303543359E+01 \\ \bottomrule
\end{tabular}
}
\end{table}
\end{document}
I read some questions talking about the csvsimple
package, can you help me read the .csv
file to create the professional table with the booktab style without entering the data in the .tex
file?
Best Answer
In case you table is going to be also large vertically, and possibly span multiple pages, you probably want to apply one of the long tables:
longtable
,xltabular
etc.Below is an example of using
csvsimple
andxltabular
. I appliedlandscape
as the table is quite wide with\newgeometry
to slightly increase margins on pages occupied by the table. I also added solutions formmakecell
to simplify code when dealing with multiple linesEDIT. ~Code generating vertical table~
Edit 2.