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

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刷新系统。用自己的记录器输出   使用Jython将参数从Java传递到Python   JavaSocksV4代理   java如何使用通知?   java@DirtiesConext不工作   java将多个jar组合成一个(使用maven)   java使用相等运算符比较两个类   java我怎样才能让两个JOptionPane一起出现在我的第一页上,并让它们在两个页面上都有正确的答案?   html无法访问java中资产文件夹内的文件   通过post命令向SpringWebApp发送对象时,java对象字段为null   单个实例中静态变量的类更改值(Java)   java解决方案是什么   试图检查网站所有受支持的密码套件的安全性,在java中遇到chacha20和poly1035问题