(f)T岛
fables的Python项目详细描述
寓言-(f)ile t(ables)
对于用户:
分析输入文件中的所有表格数据:
import fables
for parse_result in fables.parse('myfile.zip'):
for table in parse_result.tables:
print(table.name)
print(table.df.head())
for error in parse_result.errors:
print(error.message)
检查输入文件的内容:
node = fables.detect('myfile.zip')
print(node.name)
print(node.mimetype)
for child in node.children:
print(child.name)
print(child.mimetype)
注意如果您已经从detect()
中发现了输入树,
您可以将其传递到parse()
:
parse_results = parse(tree=node)
处理加密的zip
、xlsx
和xls
文件:
node = fables.detect('encrypted.xlsx')
assert node.encrypted
node.add_password('encrypted.xlsx', 'fables')
assert not node.encrypted
还可以提供密码字典(文件名->;密码) 进入检测和分析:
node = fables.detect(
'encrypted.zip',
passwords={
'encrypted.zip': 'fables',
# an encrypted file inside the zip
'encrypted.xlsx': 'foobles',
}
)
# and/or parse
parse_results = fables.parse(
'sub_dir',
passwords={
'sub_dir/encrypted.xlsx': 'fables',
'sub_dir/encrypted.xls': 'foobles',
},
)
安装
python库^{
在OSX上:
brew install libmagic
。在Windows上:this
pip install python-magic-bin
将使用 用于访问libmagic文件类型标识库的类型。
那么pip install -r requirements.txt
就可以做到了。
对于贡献者:
测试
- 所有测试:
pytest
- 覆盖范围:
pytest --cov=fables tests
- 覆盖范围:
- 集成:
pytest tests/integration
- 覆盖范围:
pytest --cov=fables tests/integration
- 覆盖范围:
- 单位:
pytest tests/unit
- 覆盖范围:
pytest --cov=fables tests/unit
- 覆盖范围:
注意所有的覆盖率统计数据都是针对语句的。
使用mypy
进行类型检查mypy fables
起毛
- 我们执行flake8:
flake8 .
同时运行测试、类型检查和棉绒
nox