My code/idea from 2 topics: Input a parameter from another file filecontents: select rows of group to display
File parameters.tex:
\documentclass{article}
\usepackage[utf8]{vietnam}
\usepackage{verbatim}
\usepackage{comment}
\usepackage{filecontents}
\begin{filecontents*}{products.tex}
No|Time|Velocity
11|"5s"|"3m/s"
22|"10s"|"7m/s"
33|"20s"|"14m/s"
\end{filecontents*}
\usepackage{datatool}
\DTLsetseparator{|}
\DTLloaddb[autokeys=false]{products}{products.tex}
\newcommand{\printtype}[1]{%
\par
\DTLforeach*
[\DTLiseq{\No}{#1}]% Condition
{products}% Database
{\No=No,\Time=Time,\Velocity=Velocity}{%
time = \Time \par max\_velocity = \Velocity
}%
}
\begin{document}
\printtype{11}
\end{document}
Compiling this parameters.tex file produces a DVI or PDF file containing:
time = 5s
max_velocity = 3m/s
But I would like to parse this output from the following main.tex file and be able to use the “time” and “max_velocity” values from within main.tex.
File main.tex:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\ior_new:N \ar_param_file
\seq_new:N \g_ar_param_seq
\cs_new:Nn \ar_read_by_line:n {%
\seq_gput_right:Nn \g_ar_param_seq {#1}% Appending the current line to the global sequence buffer
}
\NewDocumentCommand{\paraminput}{O{}m}{%
\seq_gclear:N \g_ar_param_seq% Clearing the sequence
\ior_open:Nn \ar_param_file {#2} % Open the input file
\ior_map_inline:Nn \ar_param_file {\ar_read_by_line:n{##1}}% Reading line by line
\ior_close:N \ar_param_file% Closing the line
\seq_map_inline:Nn \g_ar_param_seq {% Traversing through the line
\seq_set_split:Nnn \l_tmpa_seq {=} {##1} % Splitting each line into 'key=value' pairs
\seq_if_in:NxT \l_tmpa_seq {#1} {\seq_item:Nn \l_tmpa_seq {2}\seq_map_break:}% Checking if `#1` is in the sequence and display it with \seq_item:Nn..., then break the mapping loop.
}
}
\ExplSyntaxOff
\begin{document}
The trajectory travels the distance of
\paraminput[time]{parameters.tex}. % <==========================
The maximum observed velocity is \paraminput[max_velocity]{parameters.tex}. ...
\end{document}
I use LaTeX, texmarker?
How can I use the parameters output by parameters.tex from within main.tex? Do I need R or only LaTeX?

main.texreads data in text format, but the lines containing “time = 5s” and “max velocity = 3m/s” produced par yourparameters.tex(or paramters.tex...) are not written to a text file, they are written do DVI or PDF, depending on how you compileparameters.tex. You could either modifyparameters.texto produce a text file (using\writeor a LaTeX3 equivalent), or change your main.tex to read directly from the input file,products.tex. I don't know the parsing rules of datatool.sty (double quotes seem to be specially handled), but the second sol. seems more straightforward. – frougon Apr 12 '19 at 15:45parameters.texto produce the sentence at the end of your second file. Is this what you want to achieve? If not, please describe it more accurately. – frougon Apr 12 '19 at 16:34parameters.txtfor the output file name;parameters.texis not a great name, because the file doesn't use TeX syntax. I also improved the LaTeX3 code and formatting in yourmain.tex, see my answer below. – frougon Apr 13 '19 at 09:21