edge7″ post=83009Grazie per la celere risposta.
E adesso arriva il bello. 🙂
Il pacchetto datatool permette di manipolare i tuoi file di testo in modo piuttosto buono. C’è il problema dell’ultima riga, che si risolve leggendo due volte il file, la prima per memorizzare l’ultima riga che viene poi tolta dalla rappresentazione interna.
Unica vera modifica: avere due campi con lo stesso nome non mi pare una buona idea, così ho arbitrariamente deciso di cambiarli nel tuo file .txt; visto che è generato, non dovrebbe essere difficile cambiare il modo di scrivere i titoli dei campi.
`\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{datatool}
\usepackage{longtable}
\usepackage[top=3.0cm,right=0.5cm,bottom=3.0cm,left=0.5cm]{geometry}
\setlength{\LTleft}{0pt}
\title{AS Table \LaTeX}
\author{Scamper}
\begin{document}
\maketitle
\DTLsetseparator{;}
\chardef\uscode=\catcode`_
\catcode`\_=11
\DTLloaddb{mytable}{enrico.txt}
\DTLforeach{mytable}{\tottunn=TOT_TUNN}{%
\DTLiflastrow
{\expandafter\gdef\expandafter\lasttableentry\expandafter{\tottunn}%
\DTLremovecurrentrow}
{}%
}
\begin{longtable}{|*{11}{l|}}
\caption{As tunnel} \\
\hline
\textbf{T} & \textbf{EX} & \textbf{Lm} & \textbf{LM} & \textbf{OPQ} &
\textbf{Lm} & \textbf{LM} & \textbf{QT} & \textbf{Lm} & \textbf{LM} & \textbf{As} \\
\hline
\endfirsthead
\multicolumn{11}{l}%
{\tablename\ \thetable\ — \textit{Continued from previous page}} \\
\hline
\textbf{T} & \textbf{EX} & \textbf{Lm} & \textbf{LM} & \textbf{OPQ} & \textbf{Lm} &
\textbf{LM} & \textbf{QT} & \textbf{Lm} & \textbf{LM} & \textbf{As} \\
\hline
\endhead
\hline \multicolumn{11}{l}{\textit{Continued on next page}} \\
\endfoot
\hline
\multicolumn{11}{|l|}{\lasttableentry}\\\hline
\endlastfoot
\DTLforeach{mytable}{%
\tottunn=TOT_TUNN,
\expn=EXP_N,
\lmina=LminA,
\lmaxa=LMaxA,
\opqn=OPQ_N,
\lminb=LminB,
\lmaxb=LMaxB,
\qttln=QTTL_N,
\lminc=LminC,
\lmaxc=LMaxC,
\asname=AS_NAME}{%
\tottunn & \expn & \lmina & \lmaxa & \opqn & \lminb &
\lmaxb & \qttln & \lminc & \lmaxc & \asname
\DTLiflastrow
{}
{\\}%
}
\end{longtable}
\catcode`\_=\uscode
\end{document}`
Un paio di trucchetti biechi per evitare problemi con [tt]_[/tt] e la tabella è servita. 😉
Queste le prime righe del file .txt modificato:
`TOT_TUNN;EXP_N;LminA;LMaxA;OPQ_N;LminB;LMaxB;QTTL_N;LminC;LMaxC;AS_NAME;
15;15;1;4;0;–;–;0;–;–;AS1267_AS1267-MNT;
2;2;–;2;0;–;–;0;–;–;AS1273_CW-EUROPE-GSOC;`
Ciao
Enrico