title: Using a csv file for plots and tables in LaTeX
body: <p>I am new to LaTeX and am hoping to use it for plotting graphs for my thesis. For the most part I find it easy to use. I have no problem plotting a function, but I <strong>cannot get it to plot from an external csv file</strong>. I've seen numerous tutorials and examples and I've even copied and pasted code from those, but I can't get anything to work. The error I get is:</p>
  <p><strong>Package pgfplots Error: Could not read table file 'HeatSources.csv' in 'search path=.'</strong></p>
  <p>I think part of the issue I am having is not getting a complete example. Tutorials and examples posted on here typically show a small data set defined at the beginning of the tex file with no complete instructions on how the syntax should look for using a file saved on the computer. I've included the <strong>entire</strong> code for one of my tutorials below. The plot never shows up and I always get the error I mentioned above ^^. <strong>Can anyone show me the EXACT syntax for reading in a csv file including what the file path should look like?</strong> Or does anyone know if I am waaaay off base and there is something else wrong with the code?</p>
  <pre><code>\documentclass{standalone}
  
  \usepackage{tikz}
  \usepackage{pgfplots}
  \usepackage{siunitx}
  \usepackage{csvsimple}
  
  
  \pgfplotsset{compat=newest} % Allows to place the legend below plot
  \usepgfplotslibrary{units} % Allows to enter the units nicely
  
  \sisetup{
    round-mode          = places,
    round-precision     = 2,
  }
  
  \begin{document}
  \begin{tikzpicture}
  \begin{axis}[
  xmin = 0, xmax = 30,
  ymin = -1.5, ymax = 2.0,
  xtick distance = 5,
  ytick distance = 1,
  grid = both,
  minor tick num = 1,
  major grid style = {lightgray},
  minor grid style = {lightgray!25},
  width = \textwidth,
  height = 0.5\textwidth,
  ]
  
  
  % add a plot using a file where values are separated by spaces
  \addplot[
  smooth,
  thin,
  red,
  dashed
  ] table[col sep=comma, x=Time from start of January 1 (h), y=Transformer (W)]
  {HeatSources.csv}{/C:/Users/kayla/OneDrive/Documents/Plots and graphics/HeatSources.csv};
  
  \end{axis}
  \end{tikzpicture}
  \end{document}
  </code></pre>
  <p>Oh and the first few rows of the csv file look like this:</p>
  <pre><code>Time from start of January 1 (h),Transformer (W),Elec equipment + lighting (W),Water tanks (W)
  0.042,5.4,1194.5,43.75690471
  0.125,150,1035,44.32023815
  </code></pre>
  <p>Thank you!</p>