I try to create a table with a column for date and time from a file data.txt
. I can create a diagram but when I type \pgfplotstabletypeset
for a table following error occurs:
! Package pgfplots Error: Table 'data.txt' appears to have too many columns in line 1:
I also tried adding the option \pgfplotstabletypeset[col sep=comma]{data.txt}
. Then I get this error:
! Package PGF Math Error: Could not parse input '2015-09-13 21:00:00' as a floating point number, sorry.
How can I fix this? Thank you!
\documentclass{article}
\usepackage{pgfplotstable}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=1.15}
\usepackage{filecontents}
\begin{filecontents*}{data.txt}
date, value
2015-09-13 21:00:00, 922
2015-09-13 22:00:00, 3993
2015-09-13 23:00:00, 3003
2015-09-14 00:00:00, 991
2015-09-14 01:00:00, 2021
2015-09-14 02:00:00, 841
2015-09-14 03:00:00, 2812
2015-09-14 14:00:00, 991
2015-09-14 15:00:00, 231
2015-09-14 16:00:00, 678
\end{filecontents*}
\begin{document}
\pgfplotstabletypeset[
columns/date/.style={date type={\day.\month.\year},
column name=Datum},
columns/date/.style={date type={\hour:\minute},
column name=Zeit},
columns/value/.style={column name=Value},
]{data.txt}
\end{document}
col sep=comma
, because that's how columns are seperated indata.txt
and 2)date type
does not support time, therefore\hour
and\minute
are not defined. The easy way out would be to changedata.txt
to 3 columns (date, time, value) and usestring type
for the time. If this can't be done, it is probably possible to write some macrs to handle the first column (but currently I don't have the time for this, sorry).string type
works fine.