简体   繁体   中英

Best Data Structure/file to store Matrix to read in Ruby on Rails? jSon? Yaml? Xml?

I am choosing an optimal data file/source/database to store a matrix, originally from spreadsheet. The current spreadsheet matrix looks like below:

    A1 A2 A3 A4
B1  1  2  3  4
B2  3  2  3  4
B3  2  3  1  3

My objective is to easily retrieve data from the matrix. The column and row headings act as pointer to the actual data in the matrix.

I am considering json, yaml...but it is so much work to produce hashes with two pointers to every number in the matrix..

Any suggestions?

If you only need to store it and do nothing else about it, I would even go as far as use CSV saved inside a text field, nothing is as simple as that. If you do need to perform certain operations with the matrix, I would suggest trying to use something like postgres hstore: http://www.postgresql.org/docs/9.2/static/hstore.html and trying to build data representation based on that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM