用于处理文件的实用程序。

xphyle的Python项目详细描述


xphyle:非常简单的文件处理

PyPITravis CICoverage StatusCodacy BadgeDocumentation StatusDOIJOSS

logo

xphyle是一个很小的python库,可以轻松地打开压缩的 文件夹。最重要的是,xphyle将使用适当的程序(例如“gzip”)来压缩/解压缩系统中可用的文件;这几乎总是比使用相应的python库快。xphyle还提供了简化常见文件i/o操作的方法。

最新版本的xphyle(4.0.0+)需要python 3.6。旧版本的xphyle支持python 3.4+。

安装

pip install xphyle

从源构建

克隆此存储库并运行

make

示例用法:

fromxphyleimport*fromxphyle.pathsimportSTDIN,STDOUT# Open a compressed file...myfile=xopen('infile.gz')# ...or a compressed stream# e.g. gzip -c afile | python my_program.pystdin=xopen(STDIN)# Easily write to the stdin of a subprocesswithopen_('|cat','wt')asprocess:process.write('foo')# We have to tell xopen what kind of compression# to use when writing to stdoutstdout=xopen(STDOUT,compression='gz')# The `open_` method ensures that the file is usable with the `with` keyword.# Print all lines in a compressed file...withopen_('infile.gz')asmyfile:forlineinmyfile:print(line)# ... or a compressed URLwithopen_('http://foo.com/myfile.gz')asmyfile:forlineinmyfile:print(line)# Transparently handle paths and file objectsdefdostuff(path_or_file):withopen_(path_or_file)asmyfile:forlineinmyfile:print(line)# Read all lines in a compressed file into a listfromxphyle.utilsimportread_lineslines=list(read_lines('infile.gz'))# Sum the rows in a compressed file where each line is an integer valuetotal=sum(read_lines('infile.gz',convert=int))

有关完整用法信息,请参见Documentation

问题

请使用issue tracker报告错误并请求增强功能。

路线图

未来的版本是使用GitHub Projects绘制的。

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

推荐PyPI第三方库


热门话题
java更改计算器不显示更改   java计算沿相对对角线的点偏移   当我用javac编写几个。java文件,我有一些“重复类”错误,但我在代码中找不到错误   java Trim ArrayList根据位置设置一个数字   java使用Optional映射和返回未使用的数据   java在28字节分配的Android上内存不足   java如何在一个组件中创建实例,而在另一个组件中使用实例?   java Apache Maven:找不到符号,目标发布错误无效(NetBeans支持Mule插件)   java任何序列化“javax”的方法。艾尔。LambdaExpression`?   java使用一个单词将一个单词分成两行   java为什么ClassCastException只在运行时发生?   java如何在JavaFX中重新启动计时器?   java如何从cucumber数据表更新Json有效负载中的多个字段   http Java请求仅在以下情况下工作   java如何使用Struts 2.0更改web应用程序的会话超时?   不按java网格宽度动态设置   java ask错误加载抽绳   java Jersey 2状态代码在HttpServletResponseWrapper中不可见