Bill Guindon
12/8/2005 10:20:00 PM
On 12/8/05, Oscar Gonzalez <rakxzo@gmail.com> wrote:
> akonsu wrote:
How accurate is this example? Just wondering if the mockup has
copy/paste errrors. more below...
> DataGroup = {
> [1] = {
> [1] = {
> ["dataidentifier"] = {
> [1] = {
> ["type"] = 1,
> ["x"] = 45.5,
> ["count"] = 1,
> ["image"] = 4,
> ["y"] = 18.8,
> },
> [1] = {
Does the [1] really repeat here, or should this be [2] (or some other number)?
> ["type"] = 1,
> ["x"] = 21.5,
> ["count"] = 5,
> ["image"] = 4,
> ["y"] = 31.8,
> },
Should there be a '}' here to close off the 'dataidentifier'?
> },
> [2] = {
> ["dataidentifier2"] = {
> [1] = {
> ["type"] = 1,
> ["x"] = 74.5,
> ["count"] = 1,
> ["image"] = 3,
> ["y"] = 11.8,
> },
> [1] = {
> ["type"] = 1,
> ["x"] = 27.5,
> ["count"] = 5,
> ["image"] = 3,
> ["y"] = 36.8,
> },
> },
I'm assuming any missing '}' here would be at the end of the file.
If my guesses are right, it wouldn't be too tough to convert this
quickly with something along the lines of:
require 'pp'
text = File.read('some.log')
text.gsub!(/Datagroup = /, '')
text.gsub!(/\["?(.*?)"?\] =/, '"\1" =>')
datagroup = eval(text)
pp datagroup
--
Bill Guindon (aka aGorilla)