title: Write from CSV to yaml file?
body: <p>Wondering if anyone can help me with outputting this to a yaml file?</p>
  
  <p>As at the moment it only writes the last array returned to the yaml file.</p>
  
  <pre><code>       require 'csv'
         require 'yaml'
            #fp = File.open("vatsim-row.txt")
  
  CSV.foreach("vatsim-data.txt", :col_sep =&gt;':', :row_sep =&gt;:auto, :quote_char =&gt; ":") do |row| 
  
  if (row[3] == "PILOT") and (row[13]=="EIDW" or row[13]=="EICK" or row[13]=="EINN" or row[13]=="EIKN" or row[13]=="EIDL" or row[13]=="EICM" or row[13]=="EIKY" or row[13]=="EISG" or row[13]=="EIWF" or row[13]=="EIWT" or row[11]=="EIDW" or row[11]=="EICK" or row[11]=="EINN" or row[11]=="EIKN" or row[11]=="EIDL" or row[11]=="EICM" or row[11]=="EIKY" or row[11]=="EISG" or row[11]=="EIWF" or row[11]=="EIWT")
  
  p row 
  
  p row.count
  
  File.open("pilots.yml", "w") {|f| f.write(row.to_yaml) }
  
  elsif row[3] == "ATC" and (row[0].slice(0, 3) == "EGC" or row[0].slice(0, 3) == "EID" or row[0].slice(0, 3) == "EIC" or row[0].slice(0, 3) == "EIN" or row[0].slice(0, 3) == "EIK" or row[0].slice(0, 3) == "EIS" or row[0].slice(0, 3) == "EIW" or row[0].slice(0, 3) == "EIM")
  
                p row
                p row.count
              end
  
        end
  </code></pre>
  
  <p>The sort of output i'm looking for in the yaml file:</p>
  
  <pre><code>---
  clients: 
   callsign: RYR87LN
      cid:        "123456"
      name:       Joe Blogs EIDW
      type:       PILOT
      lat:        "48.28681"
      long:       "-4.03478"
      altitude:   "30883"
      groundspeed:"438"
      aircraft:   B738
      p_cruise:   "300"
      dep:        LFRS
      p_alt: FL310
      arr: EIDW
      server: EUROPE-C2
      pro_rev: "100"
      rating: "1"
      squawk: "2200"
      facilitytype:
      vis_range: 
      p_flighttyp: "0"
      route: FPL-RYR87LN-IS-B738/M-ZSRWY/S-REG/EI-DAH COM/TCAS RVR/200 OPR/RYRVIRTUAL.COM DOF/110813- A/BLUE/WHITE/YELLOW /V/ TERPO UM616 KORER UN482 DEGEX UN490 BERAD UM142 INSUN UN34 EVRIN N34 BUNED
      atismsg:
      lt_atis:
      logon: "20110813151905"
      heading: "310"
      qnh_ig: "29.79"
      qnh_mb: "1008"
  </code></pre>
  
  <p>If anyone can point me in the direction that would be great!</p>