From: Max Russell Date: 2008-04-21T23:32:01+09:00 Subject: CSV nesting I have a snippet of code that looks like this: next if row.nil? for i in 0...row.length next if row[i].nil? f.puts " <#{fields[i]}>#{row[i]}" end this is part of a small script that parses a CSV document and then creates an XML output file. However, I would like to add support for nesting elements in the output, so that if the current column/value is surname or forename I can write my output in a nested fashion: Brown Bobby The problem I'm having is with the identification of the current element as either SURNAME or FORENAME I've tried using: if #{fields[i]} == "" (where fields is CSV.shift) and I've also tried if row[i].data == 'ORGANISATION_PERSON_SURNAME' What is the best way of acessing this please? I've attached my original script for perusal. Attachments: http://www.ruby-forum.com/attachment/1765/csv_xml.rb -- Posted via http://www.ruby-forum.com/.