美文网首页
分割文本

分割文本

作者: rong酱 | 来源:发表于2021-01-05 23:01 被阅读0次
split -l 1000 file

感觉shell真的是很好的命令,简简单单的命令行,

#!/usr/bin/env python 
# -*- coding:utf-8 -*-

import gzip

with gzip.open('369.R1.adapter.fastq.gz','rb') as reader:
    counter = 0
    findex = 0 
    for line in reader:
        if counter == 0:
            writer = gzip.open('file'+str(findex)+'.gz','wb')
        counter +=1
        writer.write(line)
        if counter >=100000:
           writer.close()
           counter = 0
           findex +=1

相关文章

网友评论

      本文标题:分割文本

      本文链接:https://www.haomeiwen.com/subject/fodgoktx.html