I am using TikZ and I want to produce several graphs from a data file. The file contains many lines with three numbers x y r. I want to use each line and draw a circle with \draw (\x,\y) circle(\r); where \x, \y and \r have been assigned the values read on a line. Is there a way to make a \foreach-like loop to make this ? I could change the lines into x/y/z if necessary to run something like

\foreachline \x/\y/\r in {filename} {
   \draw (\x,\y) circle(\r);



You could use something like datatool or csvsimple if you wanted:

1, 2, 3
4, 5, 2
3, 1, 4


\csvreader[no head]{\jobname.csv}{1=\first, 2=\second, 3=\third}%
  {\tikz \draw (\first, \second) circle (\third);
    FYI, I used these numbers: \first, \second, \third.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.