Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6839

How do i strip CSV's "Cell" designation when migrating to YAML

Newsgroups comp.lang.ruby
Date 2013-06-20 17:47 -0700
Message-ID <374b5041-0d3d-4c15-a3f1-d19d49d1f1f1@googlegroups.com> (permalink)
Subject How do i strip CSV's "Cell" designation when migrating to YAML
From lfast1234@gmail.com

Show all headers | View raw


In some magical way ruby is maintaining the 'Cell' designation from my .csv data as I transform it into a yaml file.  I don't want that.  Any idea how i get rid of it?

Source: 
location,server_env   (heading line)
van,cpci              (content line)
...

Desired output
fleetmanifest:
  location: van
  server_env: cpci

Actual Output
  fleetmanifest: 

    ? !str:CSV::Cell location
    : !str:CSV::Cell van

    ? !str:CSV::Cell server_env
    : !str:CSV::Cell cpci1

Current Transformation code
  fleetH = {}
  myCSV.each { |row|
    # Find the header row based on 0th column
    if headerrow
      hd_row = row
    end
    if datarow
      hd_row.zip(row).each { |k,v|
        fleetH[k] = v
      }
      break
    end
  }
  puts fleetH.class   => Hash
  puts fleetH.to_yaml => produces the ? !str:CSV::Cell gibberish!

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How do i strip CSV's "Cell" designation when migrating to YAML lfast1234@gmail.com - 2013-06-20 17:47 -0700
  Re: How do i strip CSV's "Cell" designation when migrating to YAML lfast1234@gmail.com - 2013-06-21 06:50 -0700
    Re: How do i strip CSV's "Cell" designation when migrating to YAML samtreweek@gmail.com - 2015-10-02 08:55 -0700
      Re: How do i strip CSV's "Cell" designation when migrating to YAML "WJ" <w_a_x_man@yahoo.com> - 2015-10-14 13:50 +0000

csiph-web