!NuxCISwYQJuyWwNsEI:matrix.org

PGF/TikZ

56 Members
https://github.com/pgf-tikz13 Servers

Load older messages


SenderMessageTime
11 Dec 2023
@_discord_309408702530846730:t2bot.iomatrix-t2bot joined the room.15:57:34
19 Jan 2024
@manis:matrix.orgManis joined the room.21:49:02
20 Jan 2024
@manis:matrix.orgManisHi. I've seen it's quite silent in here, but maybe somebody has an idea: I'm struggling to get /pgfplots/table/string replace* to work; it only replaces digits in numbers but not words in a string. Is this the expected behaviour?09:03:46
@marei:im.f3l.demarei
In reply to @manis:matrix.org
Hi. I've seen it's quite silent in here, but maybe somebody has an idea: I'm struggling to get /pgfplots/table/string replace* to work; it only replaces digits in numbers but not words in a string. Is this the expected behaviour?
No, but if I remember correctly it's by default not applied to the header, as it's using the preprocessor in case you use it as an option to the whole table.
09:26:26
@manis:matrix.orgManis marei: I don't have headers in this case. I'm trying to apply some abbreviation(s) to the string values read from a file's first column. 09:27:35
@marei:im.f3l.demarei
\documentclass{article}
\usepackage{pgfplotstable}

\begin{filecontents}{file.dat}
testABCtest, Header
testABCtest, Body
\end{filecontents}

\begin{document}

\pgfplotstabletypeset[string type,col sep=comma,string replace*={ABC}{abc},]
{file.dat}

\end{document}
09:34:01
@marei:im.f3l.demareiworks as expected. first line isn't replaced, second is09:34:15
@manis:matrix.orgManis

Hmm, yeah, interesting. I just tried to throw together a MWE and it worked, too :headscratch:

\documentclass{article}

\usepackage{pgfplotstable}

\pgfplotstableread[col sep=comma,header=false]{
Lorem,20,kg
Ipsum,42,m
Very long key,200,g
}\mytable

\begin{document}

\pgfplotstabletypeset[
  every head row/.style={output empty row},
  columns/0/.append style={
    string type,
    column type={l},
    postproc cell content/.append style={
      /pgfplots/table/@cell content/.add={}{:\quad}
    },
    /pgfplots/table/string replace*={Very long}{V.l.}
  },
  columns/1/.append style={
    numeric type,
    fixed,
    column type={r}
  },
  columns/2/.append style={
    string type,
    column type={l}
  }
]{\mytable}

\end{document}
09:35:10
@manis:matrix.orgManisAHA!09:36:57
@manis:matrix.orgManis It does not work when text indicator is used. 09:37:08
@manis:matrix.orgManis

cf.

\documentclass{article}

\usepackage{pgfplotstable}

\pgfplotstableread[col sep=comma,header=false,text indicator="]{
Lorem,20,kg
Ipsum,42,m
"Very long key",200,g
}\mytable

\begin{document}

\pgfplotstabletypeset[
  every head row/.style={output empty row},
  columns/0/.append style={
    string type,
    column type={l},
    postproc cell content/.append style={
      /pgfplots/table/@cell content/.add={}{:\quad}
    },
    /pgfplots/table/string replace*={Very long}{V.l.}
  },
  columns/1/.append style={
    numeric type,
    fixed,
    column type={r}
  },
  columns/2/.append style={
    string type,
    column type={l}
  }
]{\mytable}

\end{document}
09:37:13
@marei:im.f3l.demareiI'd expect that one to add grouping, and that would explain why it doesn't work.09:50:57
@manis:matrix.orgManisShouldn't the quotes be removed before the cell's contents are further processed?09:55:23
@marei:im.f3l.demareiThey are. But changed to a group. -> I send you a direct message with an example guess we shouldn't spam that channel too much09:56:11
@manis:matrix.orgManisOK, thank you.09:56:26
@hmenke:matrix.orghmenke
In reply to @marei:im.f3l.de
They are. But changed to a group. -> I send you a direct message with an example guess we shouldn't spam that channel too much
Discussion about how to use pgfplotstable is not spam. This is literally what the channel is for. Please feel free to continue here.
10:29:21
@marei:im.f3l.demareiOkay, thanks for clarifying, i was not sure as we were at some specific example at that point. - but actually i now learned, that the text indicator add grouping which is quite nice to know. 10:31:08
@manis:matrix.orgManisYeah, it came as a surprise to me.10:34:20
@manis:matrix.orgManisI expected it to behave in a more CSV way to prevent separators inside the text indicator to split fields.10:34:55
@manis:matrix.orgManisI don't know if it makes sense, since AFAIK {} in the table data also create groups, don't they?10:35:50
@manis:matrix.orgManis If I want to string replace*={ }{\,}, do I need to expand \, first? 10:54:19
@manis:matrix.orgManis As it is, it replaces [space] with a literal \, 10:54:35
@manis:matrix.orgManis * As it is, it replaces [space] with \, verbatim. 10:54:44
@manis:matrix.orgManisI solved this thing outside of TeX. I'll just add the thin spaces in the input file already.11:11:02
@manis:matrix.orgManis

Another problem popped up, though. If my \pgfplotstabletypeset is inside a command into which I want to inject additional pgfkeys, do I need to treat them in a special way?

This does not work:

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma,header=false]{
foo,42
}\mytable

\newcommand{\plottable}[2][]{
  \pgfplotstabletypeset[
    every head row/.style={output empty row},
    columns/0/.append style={
      string type,
    },#1
  ]{#2}
}

\begin{document}
\plottable[
  columns/0/.append style={
    /pgfplots/table/string replace*={foo}{bar}
  }
]{\mytable}
\end{document}
11:11:59
@manis:matrix.orgManis *

Another problem popped up, though. If my \pgfplotstabletypeset is inside a command into which I want to inject additional pgfkeys, do I need to treat them in a special way?

This does not work:

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma,header=false]{
foo,42
}\mytable

\newcommand{\plottable}[2][]{
  \pgfplotstabletypeset[
    every head row/.style={output empty row},
    columns/0/.append style={
      string type
    },#1
  ]{#2}
}

\begin{document}
\plottable[
  columns/0/.append style={
    /pgfplots/table/string replace*={foo}{bar}
  }
]{\mytable}
\end{document}
11:12:12
@manis:matrix.orgManis Ah, I must not have any newlines in the optional argument to \plottable. But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1? 11:15:53
@marei:im.f3l.demarei
In reply to @manis:matrix.org
If I want to string replace*={ }{\,}, do I need to expand \, first?
If you typeset the table/ content it would be expanded later. In the cell itself it's not. and that's also what I would expect. To get the thinspace directly you would have to change the category code otherwhise it's just a space.
15:18:46
@marei:im.f3l.demarei
In reply to @manis:matrix.org
Ah, I must not have any newlines in the optional argument to \plottable. But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1?

and that's also an issue with spaces… as spaces are preserved in that setup. so

15:19:42
@marei:im.f3l.demarei
In reply to @manis:matrix.org
Ah, I must not have any newlines in the optional argument to \plottable. But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1?
*

and that's also an issue with spaces… as spaces are preserved in that setup. so

\plottable[
  columns/0/.append style={
    /pgfplots/table/string replace*={foo}{bar}
  }%
]{\mytable}

would work, or

\plottable[
  columns/0/.append style={
    /pgfplots/table/string replace*={foo}{bar}
  }]{\mytable}
15:21:12

Show newer messages


Back to Room ListRoom Version: 6