(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)

处理加密的zipxlsxxls文件:

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上:thispip 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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java我是否需要构造一个带有*非final*但不可变字段的不可变类?   java如何使用jaxb读取属性?   java为什么不打印空值以外的任何内容?   java Struts2如何在不使用struts的情况下重定向到操作。xml?   java方法参数未在其实现中使用   在Java中更改终端内部的变量   Spring中的java依赖项注入失败   java如何使用getAttribute Selenium防止获取重复的HREF   优先级队列的java顺序不符合预期   java如何使用Spring TaskExecutor在应用程序的所有请求中使用单个任务池   java Firebase RecyclerView不会从数据库中检索项目并将其显示在屏幕上。屏幕是空的   java将YUV_420_888转换为字节数组   spring停止使用Java缓存文件   java在执行maven clean安装时,我在eclipse智能家居中遇到了这种错误   stream Java=下载缓冲区未满?冲洗/缓冲是如何工作的?   查询SQL server时重置java JDBC连接   java如何避免在两个函数中使用相同的逻辑。   转换java。lang.Boolean到Scala Boolean