# \useplot with Text in CSV

Is there a way to import & auto-plot a graph containing text in one column?

Eg. Here's my table

Period,Unit Sales (in thousands)
Q1 '07,24943
Q2 '07,27855
Q3 '07,32752
Q4 '07,36766


Edit:

Here's what I've tried:

\begin{tikzpicture}
\begin{axis}[
xlabel = Period,
ylabel = Unit Sales (thousands)]
\end{axis}
\end{tikzpicture}


This turns out to be a bit trickier than it looks: you need to turn the symbolic input into a number and back again to allow plotting. For example, the following seems to work:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.csv}
Period,Unit Sales (in thousands)
Q1 '07,24943
Q2 '07,27855
Q3 '07,32752
Q4 '07,36766
\end{filecontents*}
\usepackage{pgfplots}
\newcommand*{\parseperiod}{}
\def\parseperiod Q#1 '#2\relax{\def\pgfmathresult{0.20#2#1}}
\newcommand*{\parseinvperiod}{}
\def\parseinvperiod #1.#2#3#4#5#6#7\relax{\def\pgfmathresult{Q#6 '#4#5}}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
ybar,
x coord trafo/.code = {\expandafter\parseperiod#1\relax},
x coord inv trafo/.code = {\parseinvperiod#1\relax},
xticklabel = {\tick},
xtick = data,
xlabel = Period,
ylabel = Unit Sales (thousands)]

The idea here is to parse the horizontal labels and turn them into numbers using the low-level x coord trafo key. I've done that by grabbing the quarter and the year, and making them into numbers that read 0.20<year><quarter>. To actually print the labels, you then have to turn that back into text using x coord inv trafo. Ther is also a bit of trickery to only have x-axis labels for the data itself (xtick = data) and to avoid any parsing of the labels at that point (xticklabel = {\tick}).