From: Johnny Morrice Date: 2011-01-12T10:25:05+09:00 Subject: Re: Migrate data from .csv to .yml On Wed, 12 Jan 2011 09:49:18 +0900 Kamarulnizam Rahim wrote: > Hi, > > Does anyone has any parsers or examples or guidelines on how to > convert csv data into YAML (.yml) format? I counldnt find any > appropriate guideline that explains how to do this. Any link or > example that explains how to do this is welcomed. Thanks > > Nizam > First you need to parse the CSV, using the standard library. Then you need to attribute some sort of semantic meaning to it. I'd do this by arranging it into data structures. Then you would convert it to yaml, again using the standard library. Here is an example, tested with ruby 1.8.7. It converts a CSV database into an array of maps, and then serializes it to YAML. http://pastebin.com/nJMy0Fun Have fun, Johnny