[Tutor] Python code to split and reassemble files

Eric Walstad eric at ericwalstad.com
Mon Oct 2 18:16:36 CEST 2006


Andrew Robert wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Never mind.. :)
> 
> 
> found it at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800
> 
> However, if someone has something better, I would be very interested.

Hi Andrew,

If you are on a *nix machine you could use split and cat:

"""
SPLIT(1)

NAME
        split - split a file into pieces

SYNOPSIS
        split [OPTION] [INPUT [PREFIX]]

DESCRIPTION
        Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; 
default size is 1000 lines, and default PREFIX is ‘x’.
"""

"""
CAT(1)

NAME
        cat - concatenate files and print on the standard output

SYNOPSIS
        cat [OPTION] [FILE]...

DESCRIPTION
        Concatenate FILE(s), or standard input, to standard output.
"""



More information about the Tutor mailing list