# Re: Nonlinear scaling - could symbols help solve this?

**URL:** <https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760>\
**Category:** Ruby\
**Created:** [May 17, 2006, 8:55am UTC](https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760 "2006-05-17T08:55:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [May 17, 2006, 8:55am UTC](https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760/1 "2006-05-17T08:55:29Z")

</div>

M. Edward (Ed) Borasky wrote:

> > Thanks for the response.
> > 
> > You are right that my CSV file is very much like a database table (used to load database tables). However, my XML document is not so tree-like and actually fits pretty \> well into a hash of hashes of arrays.  
> > A non-tree-like XML document? Are you _required_ by the downstream user  
> > to create XML?

Yes, the XML document and its structure is part of a legacy system for  
importing data into a database. Crazy hey - we convert a database like  
format into a hash of hashes of arrays and then the legacy system reads  
the data out of the XML document and inserts it into the database?!?

The initial csv file is a format that I have created to import directly  
into the database but unfortunately not all customers are upgrading to  
the latest system so we end up having to be backward compatible… the  
joys of customer support.

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [May 17, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760/2 "2006-05-17T15:31:07Z")

</div>

Hmmm … this might make more sense to do with Rails than with pure Ruby  
… you could import your CSV into a SQLite database and export the XML  
from there. Check out “Enterprise Integration With Ruby” and “Rails  
Recipes” for more ideas. SQLite is a _very_ nice little tool – all the  
comforts of an RDBMS with very little configuration and blinding speed  
on small databases.

Jeremy H. wrote:

> Yes, the XML document and its structure is part of a legacy system for importing data into a database. Crazy hey - we convert a database like format into a hash of hashes of arrays and then the legacy system reads the data out of the XML document and inserts it into the database?!?
> 
> The initial csv file is a format that I have created to import directly into the database but unfortunately not all customers are upgrading to the latest system so we end up having to be backward compatible… the joys of customer support.

–  
M. Edward (Ed) Borasky

> **[世界杯竞猜彩票-世界杯官网竞猜（集团）有限公司](http://www.linuxcapacityplanning.com/)**
>
> 世界杯竞猜彩票一直以来遵守商业道德，世界杯官网竞猜坚持诚信为本，保证诚实经营。世界杯竞猜彩票先后成为安徽省电子商务协会理事单位、安徽省网商协会会员单位、合肥市电子商务协会理事单位、合肥市服务外包行业协会会员单位、安徽省云计算产业促进会会员单位。世界杯官网竞猜一直保持良好的技术及服务态度，更好地为客户服务。

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [May 17, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760/3 "2006-05-17T15:56:34Z")

</div>

On 5/17/06, M. Edward (Ed) Borasky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hmmm … this might make more sense to do with Rails than with pure Ruby  
> … you could import your CSV into a SQLite database and export the XML  
> from there. Check out “Enterprise Integration With Ruby” and “Rails  
> Recipes” for more ideas. SQLite is a _very_ nice little tool – all the  
> comforts of an RDBMS with very little configuration and blinding speed  
> on small databases.

You can also try my xmlcodec package:

[http://rubyforge.org/projects/xmlcodec/](http://rubyforge.org/projects/xmlcodec/)

Defining an importer/exporter for a XML format is very easy, all you  
have to do is write some simple ruby classes. After that you’ll get  
API’s to import/export documents. For your case you can use the  
partial export API to create the XML as you go without representing it  
all in memory.

Greetings,

Pedro.

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [May 17, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/re-nonlinear-scaling-could-symbols-help-solve-this/60760/4 "2006-05-17T17:41:02Z")

</div>

On 5/17/06, M. Edward (Ed) Borasky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hmmm … this might make more sense to do with Rails than with pure Ruby  
> … you could import your CSV into a SQLite database and export the XML  
> from there.

Well, with ActiveRecord[1], anyways. I don’t see the need for a full  
Rails stack with controllers and views, but a script that leverages  
ActiveRecord to read the data out of an SQLite DB can be useful.

But really, if it’s in CSV already, and there’s not any/many  
relationships, just use FasterCSV[2] to read the CSV file, then take  
advantage of something like Builder[3] or xmlcodec[4] to output the  
resulting XML.

Jacob F.

[1] [http://api.rubyonrails.org/](http://api.rubyonrails.org/)  
[2] [http://fastercsv.rubyforge.org/](http://fastercsv.rubyforge.org/)  
[3]  
[Creating XML with Ruby and Builder](http://www.xml.com/pub/a/2006/01/04/creating-xml-with-ruby-and-builder.html)  
[4] [http://rubyforge.org/projects/xmlcodec/](http://rubyforge.org/projects/xmlcodec/)
