pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.08k stars 104 forks source link

[datavisualization] Parse error on `data[read from file]` #342

Open pgf-tikz-bot opened 9 years ago

pgf-tikz-bot commented 9 years ago

Migrated from SourceForge Author: drihyx Timestamp: 2014-12-04 08:17:00.994000

Hi,

I'm getting a parse error trying to load CSV data with a headline from a file. The same content works inline, and when the headline is omitted.

This reproduces the error I'm seeing with tikz 3.0.0:


\documentclass{article}
\usepackage{tikz,filecontents}
\usetikzlibrary{datavisualization}
\begin{document}

\iffalse
\begin{filecontents*}{sample.csv}
x,y
1,2
3,4
\end{filecontents*}
\tikz\datavisualization[scientific axes,visualize as line]
data[read from file=sample.csv];
%! Package PGF Math Error: Sorry, an internal routine of the floating point unit
% got an ill-formatted floating point number `'. The unreadable part was near ''
%..
\fi

\tikz\datavisualization[scientific axes,visualize as line]
data{x,y
1,2
3,4};
%ok

\begin{filecontents*}{sample.csv}
1,2
3,4
\end{filecontents*}
\tikz\datavisualization[scientific axes,visualize as line]
data[headline={x,y},read from file=sample.csv];
%ok

\tikz\datavisualization[scientific axes,visualize as line]
data[headline={x,y}]{1,2
3,4};
%ok

\begin{filecontents*}{sample.csv}
x=1, y=2
x=3, y=4
\end{filecontents*}
\tikz\datavisualization[scientific axes,visualize as line]
data[format=named,read from file=sample.csv];
% ok

\end{document}
````~
pgf-tikz-bot commented 9 years ago

Migrated from SourceForge Author: drihyx Timestamp: 2014-12-04 23:23:27.214000

Found another bug when parsing external files: string values in the last column appear to not have their right whitespace (the linebreak) trimmed.

Data that works inline in the first block doesn't when read from a file in the second block, I'm guessing because it's using set="a " for the datapoints. Was expecting the third block to produce an error due to the unused fourth column, but it turns out to be a workaround.


\documentclass{article}
\usepackage{tikz,filecontents}
\usetikzlibrary{datavisualization}
\begin{document}

\tikz\datavisualization
[scientific axes,visualize as line=a]
data[headline={x,y,set}]{
1,2,a
3,4,a
};
%ok

\begin{filecontents*}{sample.csv}
1,2,a
3,4,a
\end{filecontents*}
\tikz\datavisualization
[scientific axes,visualize as line=a]
data[headline={x,y,set},read from file=sample.csv];
%no points matched

\begin{filecontents*}{sample.csv}
1,2,a,
3,4,a,
\end{filecontents*}
\tikz\datavisualization
[scientific axes,visualize as line/.list=a]
data[headline={x,y,set},read from file=sample.csv];
%ok

\end{document}
````~