简体   繁体   English

用于存储Matrix的最佳数据结构/文件以在Ruby on Rails中读取? JSON? YAML? XML?

[英]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.. 我正在考虑json,yaml ......但是生成哈希有很多工作,它有两个指向矩阵中每个数字的指针。

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. 如果你只需要存储它而不做任何其他事情,我甚至会使用保存在文本字段中的CSV,没有什么比这简单。 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. 如果您确实需要使用矩阵执行某些操作,我建议尝试使用类似postgres hstore: http//www.postgresql.org/docs/9.2/static/hstore.html并尝试构建基于的数据表示那。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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