filecontents: select rows of group to displaySelecting rows to be displayed with pgfplotstableIfFileExists...
Why is it that Bernie Sanders is always called a "socialist"?
Is there a way to pause a running process on Linux systems and resume later?
1990s-2000s horror alien movie with slugs infecting people through the mouth
Why Ylvis used go instead of say in phrases like Dog goes "woof"?
Do the speed limit reductions due to pollution also apply to electric cars in France?
Is the percentage symbol a constant?
How can changes in personality/values of a person who turned into a vampire be explained?
Taking an academic pseudonym?
Is this Article About Possible Mirrored Universe Junk Science?
How can I differentiate duration vs starting time
Sets that are both Sum-free and Product-free
Is there any way to play D&D without a DM?
If we can’t finish all tasks, does this mean we are doing Scrum wrong?
Neglect higher order derivatives in expression
If I tried and failed to start my own business, how do I apply for a job without job experience?
When does a person lose diplomatic status?
How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?
Why does a single AND gate need 60 transistors?
Is it possible to methodically find the total of ways to read a given phrase making a stack?
two subject complements in passive form?
Is practicing on a digital piano harmful to an experienced piano player?
Crack the bank account's password!
What does an unprocessed RAW file look like?
Buying a "Used" Router
filecontents: select rows of group to display
Selecting rows to be displayed with pgfplotstableIfFileExists and filecontents causes an errorHow to keep filecontents* from getting confused when it encloses begin{document}..end{document}?Can filecontents write an external file in a parent directory?filecontents* cannot write to file in WindowsFilecontents and newenvironment issueHow to select conditional text?Numerical conditional within tikz keys?Randomly select one of two possible textsUse filecontents everywhere in the document (including after “end{document}”)Display or hide stuff in a document
I have a file that contains 1,000 rows of product data. I want to select only a specific product type to print in my document.
Minimal code in main.tex
:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No.,Type ,Name , Description
1, 1, A1,D1
….
30, 1, A1, D30
31, 2, A2, D31
…
131,2, A2, D131
132,3,A3,D132
….
249,4,A4,D249
…
1.000,10, A10,D1000
end{filecontents*}
begin{document}
%Need command can CHOOSE Type = 1 and/or 2, and/or 3, ...10
%i choose type = 1 & 3
include{run.tex}
end{document}
Product Types range from 1, 2, ..., 10. And in run.tex
:
%Display like:
Name[i] & Description[j]
main.pdf
result:
Type = 1
A1 - D1
…
A1 - D30
Type = 3
A3 - D132
…
A3 - D248
conditionals external-files
add a comment |
I have a file that contains 1,000 rows of product data. I want to select only a specific product type to print in my document.
Minimal code in main.tex
:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No.,Type ,Name , Description
1, 1, A1,D1
….
30, 1, A1, D30
31, 2, A2, D31
…
131,2, A2, D131
132,3,A3,D132
….
249,4,A4,D249
…
1.000,10, A10,D1000
end{filecontents*}
begin{document}
%Need command can CHOOSE Type = 1 and/or 2, and/or 3, ...10
%i choose type = 1 & 3
include{run.tex}
end{document}
Product Types range from 1, 2, ..., 10. And in run.tex
:
%Display like:
Name[i] & Description[j]
main.pdf
result:
Type = 1
A1 - D1
…
A1 - D30
Type = 3
A3 - D132
…
A3 - D248
conditionals external-files
add a comment |
I have a file that contains 1,000 rows of product data. I want to select only a specific product type to print in my document.
Minimal code in main.tex
:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No.,Type ,Name , Description
1, 1, A1,D1
….
30, 1, A1, D30
31, 2, A2, D31
…
131,2, A2, D131
132,3,A3,D132
….
249,4,A4,D249
…
1.000,10, A10,D1000
end{filecontents*}
begin{document}
%Need command can CHOOSE Type = 1 and/or 2, and/or 3, ...10
%i choose type = 1 & 3
include{run.tex}
end{document}
Product Types range from 1, 2, ..., 10. And in run.tex
:
%Display like:
Name[i] & Description[j]
main.pdf
result:
Type = 1
A1 - D1
…
A1 - D30
Type = 3
A3 - D132
…
A3 - D248
conditionals external-files
I have a file that contains 1,000 rows of product data. I want to select only a specific product type to print in my document.
Minimal code in main.tex
:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No.,Type ,Name , Description
1, 1, A1,D1
….
30, 1, A1, D30
31, 2, A2, D31
…
131,2, A2, D131
132,3,A3,D132
….
249,4,A4,D249
…
1.000,10, A10,D1000
end{filecontents*}
begin{document}
%Need command can CHOOSE Type = 1 and/or 2, and/or 3, ...10
%i choose type = 1 & 3
include{run.tex}
end{document}
Product Types range from 1, 2, ..., 10. And in run.tex
:
%Display like:
Name[i] & Description[j]
main.pdf
result:
Type = 1
A1 - D1
…
A1 - D30
Type = 3
A3 - D132
…
A3 - D248
conditionals external-files
conditionals external-files
edited 4 hours ago
Werner
445k699801685
445k699801685
asked 5 hours ago
tisaigontisaigon
1587
1587
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Use datatool
for this:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No,Type,Name,Description
1,1,A1,D1
2,1,A1,D2
3,1,A1,D3
30,1,A1,D30
31,2,A2,D31
131,2,A2,D131
132,3,A3,D132
133,3,A3,D133
134,3,A3,D134
249,4,A4,D249
1000,10,A10,D1000
end{filecontents*}
usepackage{datatool}
DTLloaddb[autokeys=false]{products}{product.tex}
newcommand{printtype}[1]{%
par
section*{Type #1}
DTLforeach*
[DTLiseq{Type}{#1}]% Condition
{products}% Database
{No=No,Type=Type,Name=Name,Description=Description}{%
noindentName quad Descriptionpar
}%
}
begin{document}
Here is some text.
printtype{1}
Some breaking text here.
printtype{3}
And then some final text.
end{document}
The printtype{<type>}
command uses DTLforeach
to cycle through the products
database and print only items where the Type
equals <type>
. You can format the presentation however you want.
add a comment |
This is an answer heavily based on this answer. The main point here is to remark that you need to do pgfplotsinvokeforeach
in order to loop over the types you want typeset, and not foreach
.
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.dat}
No.,Type,Name,Description
1, 1, A1,D1
2, 1, A1,D2
30, 1, A1, D30
31, 2, A2, D31
131,2, A2, D131
132,3,A3,D132
249,4,A4,D249
1.000,10, A10,D1000
end{filecontents*}
usepackage{amsmath,amssymb}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
begin{document}
pgfplotstableread[col sep=comma]{product.dat}{data}
pgfplotsinvokeforeach{1,3}{
subsection*{boldmath$text{Type}=#1$}
pgfplotstabletypeset[string type,
row predicate/.code={%
pgfplotstablegetelem{##1}{Type}of{data}
ifnumpgfplotsretval=#1relax
elsepgfplotstableuserowfalsefi}
]{data}
}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476354%2ffilecontents-select-rows-of-group-to-display%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use datatool
for this:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No,Type,Name,Description
1,1,A1,D1
2,1,A1,D2
3,1,A1,D3
30,1,A1,D30
31,2,A2,D31
131,2,A2,D131
132,3,A3,D132
133,3,A3,D133
134,3,A3,D134
249,4,A4,D249
1000,10,A10,D1000
end{filecontents*}
usepackage{datatool}
DTLloaddb[autokeys=false]{products}{product.tex}
newcommand{printtype}[1]{%
par
section*{Type #1}
DTLforeach*
[DTLiseq{Type}{#1}]% Condition
{products}% Database
{No=No,Type=Type,Name=Name,Description=Description}{%
noindentName quad Descriptionpar
}%
}
begin{document}
Here is some text.
printtype{1}
Some breaking text here.
printtype{3}
And then some final text.
end{document}
The printtype{<type>}
command uses DTLforeach
to cycle through the products
database and print only items where the Type
equals <type>
. You can format the presentation however you want.
add a comment |
Use datatool
for this:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No,Type,Name,Description
1,1,A1,D1
2,1,A1,D2
3,1,A1,D3
30,1,A1,D30
31,2,A2,D31
131,2,A2,D131
132,3,A3,D132
133,3,A3,D133
134,3,A3,D134
249,4,A4,D249
1000,10,A10,D1000
end{filecontents*}
usepackage{datatool}
DTLloaddb[autokeys=false]{products}{product.tex}
newcommand{printtype}[1]{%
par
section*{Type #1}
DTLforeach*
[DTLiseq{Type}{#1}]% Condition
{products}% Database
{No=No,Type=Type,Name=Name,Description=Description}{%
noindentName quad Descriptionpar
}%
}
begin{document}
Here is some text.
printtype{1}
Some breaking text here.
printtype{3}
And then some final text.
end{document}
The printtype{<type>}
command uses DTLforeach
to cycle through the products
database and print only items where the Type
equals <type>
. You can format the presentation however you want.
add a comment |
Use datatool
for this:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No,Type,Name,Description
1,1,A1,D1
2,1,A1,D2
3,1,A1,D3
30,1,A1,D30
31,2,A2,D31
131,2,A2,D131
132,3,A3,D132
133,3,A3,D133
134,3,A3,D134
249,4,A4,D249
1000,10,A10,D1000
end{filecontents*}
usepackage{datatool}
DTLloaddb[autokeys=false]{products}{product.tex}
newcommand{printtype}[1]{%
par
section*{Type #1}
DTLforeach*
[DTLiseq{Type}{#1}]% Condition
{products}% Database
{No=No,Type=Type,Name=Name,Description=Description}{%
noindentName quad Descriptionpar
}%
}
begin{document}
Here is some text.
printtype{1}
Some breaking text here.
printtype{3}
And then some final text.
end{document}
The printtype{<type>}
command uses DTLforeach
to cycle through the products
database and print only items where the Type
equals <type>
. You can format the presentation however you want.
Use datatool
for this:
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.tex}
%Type =1,2...10
No,Type,Name,Description
1,1,A1,D1
2,1,A1,D2
3,1,A1,D3
30,1,A1,D30
31,2,A2,D31
131,2,A2,D131
132,3,A3,D132
133,3,A3,D133
134,3,A3,D134
249,4,A4,D249
1000,10,A10,D1000
end{filecontents*}
usepackage{datatool}
DTLloaddb[autokeys=false]{products}{product.tex}
newcommand{printtype}[1]{%
par
section*{Type #1}
DTLforeach*
[DTLiseq{Type}{#1}]% Condition
{products}% Database
{No=No,Type=Type,Name=Name,Description=Description}{%
noindentName quad Descriptionpar
}%
}
begin{document}
Here is some text.
printtype{1}
Some breaking text here.
printtype{3}
And then some final text.
end{document}
The printtype{<type>}
command uses DTLforeach
to cycle through the products
database and print only items where the Type
equals <type>
. You can format the presentation however you want.
answered 4 hours ago
WernerWerner
445k699801685
445k699801685
add a comment |
add a comment |
This is an answer heavily based on this answer. The main point here is to remark that you need to do pgfplotsinvokeforeach
in order to loop over the types you want typeset, and not foreach
.
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.dat}
No.,Type,Name,Description
1, 1, A1,D1
2, 1, A1,D2
30, 1, A1, D30
31, 2, A2, D31
131,2, A2, D131
132,3,A3,D132
249,4,A4,D249
1.000,10, A10,D1000
end{filecontents*}
usepackage{amsmath,amssymb}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
begin{document}
pgfplotstableread[col sep=comma]{product.dat}{data}
pgfplotsinvokeforeach{1,3}{
subsection*{boldmath$text{Type}=#1$}
pgfplotstabletypeset[string type,
row predicate/.code={%
pgfplotstablegetelem{##1}{Type}of{data}
ifnumpgfplotsretval=#1relax
elsepgfplotstableuserowfalsefi}
]{data}
}
end{document}
add a comment |
This is an answer heavily based on this answer. The main point here is to remark that you need to do pgfplotsinvokeforeach
in order to loop over the types you want typeset, and not foreach
.
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.dat}
No.,Type,Name,Description
1, 1, A1,D1
2, 1, A1,D2
30, 1, A1, D30
31, 2, A2, D31
131,2, A2, D131
132,3,A3,D132
249,4,A4,D249
1.000,10, A10,D1000
end{filecontents*}
usepackage{amsmath,amssymb}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
begin{document}
pgfplotstableread[col sep=comma]{product.dat}{data}
pgfplotsinvokeforeach{1,3}{
subsection*{boldmath$text{Type}=#1$}
pgfplotstabletypeset[string type,
row predicate/.code={%
pgfplotstablegetelem{##1}{Type}of{data}
ifnumpgfplotsretval=#1relax
elsepgfplotstableuserowfalsefi}
]{data}
}
end{document}
add a comment |
This is an answer heavily based on this answer. The main point here is to remark that you need to do pgfplotsinvokeforeach
in order to loop over the types you want typeset, and not foreach
.
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.dat}
No.,Type,Name,Description
1, 1, A1,D1
2, 1, A1,D2
30, 1, A1, D30
31, 2, A2, D31
131,2, A2, D131
132,3,A3,D132
249,4,A4,D249
1.000,10, A10,D1000
end{filecontents*}
usepackage{amsmath,amssymb}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
begin{document}
pgfplotstableread[col sep=comma]{product.dat}{data}
pgfplotsinvokeforeach{1,3}{
subsection*{boldmath$text{Type}=#1$}
pgfplotstabletypeset[string type,
row predicate/.code={%
pgfplotstablegetelem{##1}{Type}of{data}
ifnumpgfplotsretval=#1relax
elsepgfplotstableuserowfalsefi}
]{data}
}
end{document}
This is an answer heavily based on this answer. The main point here is to remark that you need to do pgfplotsinvokeforeach
in order to loop over the types you want typeset, and not foreach
.
documentclass{article}
usepackage{filecontents}
begin{filecontents*}{product.dat}
No.,Type,Name,Description
1, 1, A1,D1
2, 1, A1,D2
30, 1, A1, D30
31, 2, A2, D31
131,2, A2, D131
132,3,A3,D132
249,4,A4,D249
1.000,10, A10,D1000
end{filecontents*}
usepackage{amsmath,amssymb}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
begin{document}
pgfplotstableread[col sep=comma]{product.dat}{data}
pgfplotsinvokeforeach{1,3}{
subsection*{boldmath$text{Type}=#1$}
pgfplotstabletypeset[string type,
row predicate/.code={%
pgfplotstablegetelem{##1}{Type}of{data}
ifnumpgfplotsretval=#1relax
elsepgfplotstableuserowfalsefi}
]{data}
}
end{document}
answered 1 hour ago
marmotmarmot
103k4121233
103k4121233
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476354%2ffilecontents-select-rows-of-group-to-display%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown