Generating Plots from .csv file
<p>I'm trying to make several plots of Exoplanet data from NASA's Exoplanet Archive. The problem is nothing I do will return the columns of the csv file with the headers on the first line of the csv file.</p>

<p>The Error I get is</p>

<pre><code>    NameError: name 'pl_orbper' is not defined
</code></pre>

<p><a href="https://i.stack.imgur.com/JPKpF.png" rel="nofollow">The DATA I need to use.</a></p>

<p>The code I have currently has not worked though I'm sure I'm close.</p>

<pre><code>   import matplotlib.pyplot as plt
   import numpy as np

   data = np.genfromtxt("planets.csv",delimiter=',',names=True, unpack=True)

   plt.plot(pl_orbper,pl_bmassj)
   plt.title('Mass vs Period')
   plt.ylabel('Period')
   plt.xlabel('Mass')

   plt.show() 
</code></pre>

<p>If anyone has a better solution with csv.reader or any other ways to read csv files I'd be open to it.</p>

<p>Change the following line:</p>

<pre><code>plt.plot(pl_orbper,pl_bmassj)
</code></pre>

<p>to </p>

<pre><code>plt.plot(data['pl_orbper'],data['pl_bmassj'])
</code></pre>

<p>With the following data:</p>

<pre class="lang-none prettyprint-override"><code>rowid,pl_orbper,pl_bmassj
1, 326.03, 0.320
2, 327.03, 0.420
3, 328.03, 0.520
4, 329.03, 0.620
5, 330.03, 0.720
6, 331.03, 0.820
</code></pre>

<p>this is the result</p>

<p><a href="https://i.stack.imgur.com/ML88q.png" rel="nofollow"><img src="https://i.stack.imgur.com/ML88q.png" alt="Mass vs Period Plot"></a></p>

python csv matplotlib