我可以使用什么文本格式在Excel电子表格中显示原始数据?

我有一个Excel电子表格,有许多人对另一个人的身高和体重的估计。 此外,有些人对两个估计单位留下了评论,如“这个估计考虑到了这样那样的”。

我想从电子表格中获取数据(我已经知道如何parsing它),并用纯文本文件表示,以便我可以轻松地将其parsing为结构化格式(理想情况下使用Perl)。

本来我想用YAML:

Tom: Height: Estimate: 5 Comment: Not that confident Weight: Estimate: 7 Comment: Very confident Natalia: ... 

但现在我觉得这有点难以阅读,我想知道是否有一些文本表格表示,这将更容易阅读,仍然可以parsing。

就像是:

 PERSON HEIGHT Weight ----------------------------- Tom 5 7 ___START_HEIGHT_COMMENT___ We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed [...] Wait, what's this project about again? ___END_HEIGHT_COMMENT___ ___START_WEIGHT_COMMENT___ We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed [...] Wait, what's this project about again? ___END_WEIGHT_COMMENT___ Natalia 2 4 John 3 3 

有一个更好的方法吗?

CSV( 逗号分隔值 )。

您甚至可以直接从Excel中将此格式保存为此格式,并从此格式直接将其读取到Excel中。 但它也是人类可读的,并且易于机器parsing。

通常情况下,如果我想从文本格式的电子表格中采集数据,我使用CSV(Excel可以读写)。 它很容易生成和parsing以及与许多其他工具兼容,但在“人类可读”图表上排名不高。 它可以被读取,但是对于任何情况,除了具有相同字段宽度的简单文件以外都是很难的。

XML是一个选项,但是YAML更易于阅读。 易读性是YAML的devise目标之一。 YAML :: Tiny模块对于典型的情况来说是一个不错的和轻量级的模块。

它看起来像你想到的是一个纯文本表格,或者可能是一个固定的列表格式。 CPAN上有一些模块可能是有用的: Text :: Table , Text :: SimpleTable , 其他 …这些模块可以生成一个易读的表示,但parsing它会更困难。 (它们用于数据表示,而不是存储和检索。)您可能必须构build自己的parsing器。

添加到罗伯特的答案,你可以简单地把注释放在额外的列(逗号将被CSV等CSV输出filter转义)。 有关CSV格式的更多信息,请访问:www.csvreader.com/csv_format.php

没有理由你不能使用XML,但我可以想象在这种特殊情况下它是过度的。

还有Config :: General用于简单数据,以及相关类的族。