n00bie help with file input and parsing
jason
j_bongo79 at hotmail.com
Sat May 10 10:42:39 EDT 2003
Hi All,
I am trying to write a program which takes the input from a csv file
called input.txt. This file contains the following:
"1","2","3","10064299","5","6","7","8","9"
"1","2","3","10064862","5","6","7","8","9"
"1","2","3","10064908","5","6","7","8","9"
"1","2","3","10161170","5","6","7","8","9"
"1","2","3","10161925","5","6","7","8","9"
.....
etc.
I also have files separate text files named QH10064299.txt,
QH10064862.txt, QH10064908.txt etc.
Basically, what I need to do is parse the "10064299" string from the
input.txt file, strip the quotation marks, and add a QH and .txt onto
the end so it matches one of other separate files. Then I need to
open this file up in append mode, and add all the other information to
it.
For example, if I pulled the 10064299 from the 1st line of input, I
would then add the QH and .txt to make QH10064299.txt. Then I would
open this file for appending and append:
1
2
3
10064299
5
6
7
8
9
NB all quotes removed. Someone told me this could be written in about
10 lines of Python code, could anyone help me out? I have never
before used Python.
Apologies for the long post.
Thanks
More information about the Python-list
mailing list