title: Edit yaml file and save it with python
body: <p>I have a yaml file that looks like this:</p>
  
  <pre><code>grids:
    phxgrid:
      class: spexxy.grid.FilesGrid
      filename: /home/geoffrey/Bureau/husser_interpolator/grid.csv
  
  interpolators:
    phx:
      class: spexxy.interpolator.SplineInterpolator
      grid: phxgrid
      derivs: phxgrid
  
  components:
    star:
      class: spexxy.component.GridComponent
      interpolator: phx
      init:
      - class:    
        values:
          logg: 4.0
          Alpha: 0.
          v: 0
          sig: 0
  
  
  main:
    class: spexxy.main.ParamsFit
    components: [star]
    fixparams:
      star: [sig, Alpha, logg]
  </code></pre>
  
  <p>From a CSV file, I have to read a parameter in a column, which I already know how to do, and insert it in the yaml file to the line <code>logg: 4.0</code>, by example switching 4.0 to 3.2, and save a yaml file for each value.</p>
  
  <p>Would you know how to do this? Thanks</p>
  
  <p>EDIT:</p>
  
  <p>So, for now, I have this:</p>
  
  <pre><code>import csv
  import yaml
  from csv import reader
  
  with open('params.csv', 'r') as f:
          data = list(reader(f))
          logg_list = [i[6] for i in data[1::]]
  
  with open('config.yaml', 'rw') as ymlfile:
          doc = yaml.load(ymlfile)
  
  for logg in logg_list:
          doc['logg'] = logg[i]
          yaml.dump(doc,ymlfile)
  </code></pre>
  
  <p>But it does not change anything, and I'm not sure about the saving part as I'm supposed to obtain many yaml files with different values of logg, and I'd like to name the valid files in consequence</p>