erlug
[Top] [All Lists]

Re: [Erlug] affettare un file di testo

To: ERlug - Lista Pubblica <erlug@xxxxxxxxxxxxxx>
Subject: Re: [Erlug] affettare un file di testo
From: Marco Mariani <marco.mariani@xxxxxxxxxxxx>
Date: Mon, 28 Jul 2008 12:32:06 +0200
Federico Calboli wrote:

Io voglio un qualche unix text utility, o altro ciappino lightweight, che faccia:

'estrai da 'data' le righe specificate da 'righe' > nuovofile


#!/usr/bin/python

import sys

righe = [int(x) for x in file('righe').readlines()]

for lnum, line in enumerate(file('data')):
   if lnum+1 in righe:
       sys.stdout.write(line)


--
This e-mail (and any attachment(s)) is strictly confidential and for use only 
by intended recipient(s).  Any use, distribution, reproduction or disclosure by 
any other person is strictly prohibited. The content of this e-mail does not 
constitute a commitment by the Company except where provided for in a written 
agreement between this e-mail addressee and the Company.
If you are not an intended recipient(s), please notify the sender promptly and 
destroy this message and its attachments without reading or saving it in any 
manner.
Any non authorized use of the content of this message constitutes a violation 
of the obligation to abstain from learning of the correspondence among other 
subjects, except for more serious offence, and exposes the person responsible 
to the relevant consequences.

<Prev in Thread] Current Thread [Next in Thread>