Hi All,
I am trying to read a line in a file then split the words in the line up.
This is what i thought would work:
# filearray.py
import string
# THE FOLLOWING FOUR LINE ARE THE CORRECT START TO THE PROGRAM,
# THE SIXTH AND SEVENTH LINES ARE ONLY FOR QUICK TEST PURPOSE!!!
infilename = raw_input("What file would you like to re-arrange?: ")
outfilename = raw_input("Where would you like to save to array?: ")
infile = open(infilename, 'r')
infile = open(outfilename, 'w')
#infile = open("G:\gnet.nmap", 'r')
#infile = open("G:\work2.txt", 'w')
# process each line
for line in infile.readlines():
words = string.split(line)
print words
# save and close files
infile.close()
infile.close()
But i get an "IO Error: [Errno 9] Bad file descriptor" on line 16.
Tried changing syntax and file names, thought it was fairly simple and i
knew what i was doing. Any help appreciated.
Thanks in advance!
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor