title: How to insert equations into python script from txt file and generate another file?
body: <p>I'm asking this question again because I have not gathered a clear answer for my question. </p>
  
  <p>I have a set of equations:</p>
  
  <pre><code>ref_energy = (K-(C/2)comp(a)) + C/2
  form_E2 = relaxed_E_per_atom - ref_energy(comp_x)
  </code></pre>
  
  <p>I need to have a python script use these two equations using the values in the txt file to generate another x and y columns of values that will plot those values. </p>
  
  <p>This is the first few lines of my txt file. the config is the name of the structure associated with four values </p>
  
  <pre><code>comp(a),form_E,comp_x,relaxed_E_per_atom
  0,0,0,-8.15382173
  1,0,0.33333333,-5.25358563
  0.5,0.18614484,0.2,-6.33922213
  0.5,-0.69658919,0.2,-6.69231575
  0.5,-0.70549249,0.2,-6.69587707
  </code></pre>
  
  <p>Below is my script but I keep getting errors such as </p>
  
  <pre><code>Traceback (most recent call last):
    File "attempt_#2.py", line 80, in &lt;module&gt;
      x.append(float(row[0]))
  ValueError: could not convert string to float: 'comp(a)'
  </code></pre>
  
  <p>I assume the x value isn't a numerical value in the configname, but not sure. </p>
  
  <pre><code>#!/bin/env/python
  import numpy as np
  import matplotlib.pyplot as plt 
  import csv
  
  Columns = 'configname,comp(a),form_E,comp_x,relaxed_E_per_atom'.split(',')
  testdata ='''\
  comp(a),form_E,comp_x,relaxed_E_per_atom
  0,0,0,-8.15382173
  1,0,0.33333333,-5.25358563
  0.5,0.18614484,0.2,-6.33922213
  0.5,-0.69658919,0.2,-6.69231575
  0.5,-0.70549249,0.2,-6.69587707
  '''
  
  reader = csv.DictReader(StringIO(testdata))
  desired_cols = (tuple(row[col] for col in columns) for row in reader)   
  x=[]
  y=[]
  K=-2.69028905
  C=-32.65176322
  with open('values2.txt','r') as csvfile:
          points = csv.reader(csvfile,delimiter=',')
          for row in points:
              x.append(float(row[0]))
              y.append(float(row[1]))
  allpoints=np.loadtxt('hmm.csv',delimiter=',')
  ref_energy = (Kend-(Cend/2))*comp(a) + Cend/2
  form_E = relaxed_E_per_atom-ref_energy(comp_x)
  plt.scatter(x,y, label='Energy')
  plt.xlabel('Composition KxC',fontsize=24)
  plt.ylabel('Formation Energy per carbon (eV)',fontsize=18)
  plt.title('Convex Hull Potassium Graphite')
  plt.xticks(fontsize=20)
  plt.yticks(fontsize=20)
  plt.tight_layout()
  plt.ylim(-0.08,0)
  plt.xlim(0,1.01)
  plt.show()
  </code></pre>