没有项目描述
csvw的Python项目详细描述
CSVW
网络上的csv
链接
- github:https://github.com/cldf/csvw
- PYPI:https://pypi.org/project/csvw
- 问题跟踪器:https://github.com/cldf/csvw/issues
安装
此软件包在Python2.7和3.4+下运行,使用PIP安装:
$ pip install csvw
示例
>>>importcsvw>>>tg=csvw.TableGroup.from_file('tests/csv.txt-metadata.json')>>>tg.check_referential_integrity()>>>assertlen(tg.tables)==1>>>asserttg.tables[0]istg.tabledict['csv.txt']>>>tg.tables[0].check_primary_key()>>>fromcollectionsimportOrderedDict>>>row=next(tg.tables[0].iterdicts())>>>assertrow==OrderedDict([('ID','first'),('_col.2','line')])>>>assertlen(list(tg.tables[0].iterdicts()))==2
已知限制
- 我们读取all数据,这些数据被指定为使用
^{
} codecs 。 因此,如果此类数据以U+FEFF
开头,则将被解释为BOM 跳过了。 - 低级csv解析被委托给python标准库中的
csv
模块。因此,如果acommentPrefix
在Dialect
实例中指定,这将导致跳过第一个值开始的行 使用commentPrefix
,即使该值被引用。
与CSVW规格的偏差
当我们使用csvw规范作为指导时,这个包没有(并且 可能永远不会)实现此规范的全部范围。
- 当读取带有头的csv文件时,列不按顺序匹配
tableSchema
中的列描述,但是根据 csv列标题和列描述“name
和titles
属性。 这允许更大的灵活性,因为CSV文件中的列可能是 重新排序而不使元数据失效。可以强制进行更严格的匹配 通过用表的方言指定"header": false
和"skipRows": 1
描述。
另请参见
- https://www.w3.org/2013/csvw/wiki/Main_Page
- https://github.com/CLARIAH/COW
- https://github.com/CLARIAH/ruminator
- https://github.com/bloomberg/pycsvw
- https://github.com/frictionlessdata/goodtables-py
- https://github.com/frictionlessdata/tableschema-py
- https://github.com/theodi/csvlint.rb
- https://github.com/ruby-rdf/rdf-tabular
- https://github.com/rdf-ext/rdf-parser-csvw
许可证
这个包在Apache 2.0 license下分发。