python - python中有没有从文件中读取表的包

标签 python tabular

我使用 python 包以表格格式将一些数据存储在文件中:tabulate

>>> print tabulate(table, headers, tablefmt="orgtbl")$

表格如下所示:

| name   |   num |
|--------+-------|
| abcd   |    30 |
| efgh   |   100 |
| ijklm  |    10 |

现在我需要将这些数据提供给其他程序(用 python 编写)。 有没有简单的方法(我的意思是任何包)将表读入某些数据结构而不是显式解析它。换句话说,我可以将表格打印成其他格式(例如:网格、管道、媒体维基、 latex )是否有任何现成的解决方案可以将其从任何此类格式读入数据结构?

最佳答案

您可以看看astropy.io.ascii (以前称为 Asciitable )并查看它是否满足您的要求。

The following shows a few of the ASCII formats that are available, while the section on Supported formats contains the full list.

  • Basic: basic table with customizable delimiters and header configurations
  • Cds: CDS format table (also Vizier and ApJ machine readable tables)
  • Daophot: table from the IRAF DAOphot package
  • Ecsv: Enhanced CSV format
  • FixedWidth: table with fixed-width columns (see also Fixed-width Gallery)
  • Ipac: IPAC format table
  • HTML: HTML format table contained in a <table> tag
  • Latex: LaTeX table with datavalue in the tabular environment
  • Rdb: tab-separated values with an extra line after the column definition line
  • SExtractor: SExtractor format table

关于python - python中有没有从文件中读取表的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34107914/

相关文章:

python - 函数定义外的变量存储+内存中的变量位置?

python - 如何在 Python 中从 StringProperty 中获取字符串

html - 给表格单元格 1 px 高度的坏习惯?

html - 如何在 HTML 中的同一行(级别)显示不同的表格或数据 block

html - CSS/表格 : how to put two versions of a text side-by-side?

python - 在运行的 C++ 代码和 python 脚本之间交换信息

python - 当 MySQL Select 语句时,Flask 出现 Python 错误

python - Django 测试运行器因 "relation does not exist"错误而失败

c++ - ASCII 字符数组

latex - 表格单元格中的水平和垂直对齐