Texmaker and TeXstudio ⇒ How to insert text from an external file (.txt or .tex)
How to insert text from an external file (.txt or .tex)
The text file looks like this: (This prevents me from using "\verbatiminput" or "\input")
Mean Median SD Min Max Count
Price 6,165.3 5,006.5 2,949.5 3,291.0 15,906.0 74
MPG 21.3 20.0 5.8 12.0 41.0 74
Weight 3,019.5 3,190.0 777.2 1,760.0 4,840.0 74
Any help will be highly appreciated!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10358
- Joined: Mon Mar 10, 2008 9:44 pm
How to insert text from an external file (.txt or .tex)
The

Distribution,Hits
Mint,2364
Ubuntu,1838
Debian,1582
openSUSE,1334
Fedora,1262
Mageia,1219
CentOS,1171
Arch,1040
elementary,899
Zorin,85
Then it used this code as example:
Code: Select all
\documentclass{article}
\usepackage{booktabs}
\usepackage{datatool}
\DTLloaddb{Linux}{linux.csv}
\DTLsort[Distribution]{Hits=descending}{Linux}
\pagestyle{empty}
\begin{document}
\begin{tabular}{rlr}
& Distribution & Hits \\
\cmidrule(lr){2-2}\cmidrule(lr){3-3}
\DTLforeach{Linux}{%
\distribution=Distribution,\hits=Hits}{%
\theDTLrowi & \distribution & \hits \\}
\end{tabular}
\end{document}
You can use more complex tables, and tabs can be chosen as field separator as well by using the command
\DTLsettabseparator
.Stefan