[Tutor] Reading multiple text files and writing data on one file (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Apr 16 14:05:19 EDT 2004


[Forwarding to Tutor]

---------- Forwarded message ----------
Date: Thu, 15 Apr 2004 16:46:11 +0000
From: ABDUL JABBAR SIDDIQUE <jsidiqi at hotmail.com>
To: dyoo at hkn.eecs.berkeley.edu
Subject: Re: [Tutor] Reading multiple text files and writing data on one
    file


Danny Yoo,

thnx for your reply. yes the following code works for one file.
###
def process(inp, outp):
    i=0
    for line in inp:
        i=i+1
        if i > 5 and i <= 76:
            outp.write((line[:12]+line[88:96])+"\n")


inp = open("S_1.OUT","r")
outp1 = open ("O_1.csv","w")
process(inp, outp1)
print "1 file copied..."

# Now close the files
inp.close()
outp1.close()
###

However, I want to add columns 3,4,5,6,.... 11 in my output file
("O_1.csv"):

outp.write((line[:12]+line[88:96])+....+......+.......+"\n")

from files "S_2.OUT","S_3.OUT"......"S_10.OUT". The data to be caprtured
from "S_2,S_3, .... S_10.OUT" files lies in the same column (say column 8)
in all the .OUT files.

I will highly appreciate your reply.

Thnx

A. jabbar siddique


__________________________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*




More information about the Tutor mailing list