[Tutor] Reading lines
Daniel D. Laskey, CPA
dlaskey@laskeycpa.com
Mon, 21 Aug 2000 13:35:28 -0400
Dear Tutor:
# ---------------------------------------------------
# import sys and string
import sys
import string
# print the following statement
print "Enter the name of the datafile file to convert:"
# ask the name of the data_file to use
data_file = raw_input('File name to process? ')
# read the data_file and put it into a file called in_file
in_file = open(data_file,"r")
# create the file to export the data to
out_file = open("junk.txt","w+")
# read the file in_file line by line
lines = in_file.readlines()
# I want it to search through each line of the file
# strip out the lines that has 'Total' on it
# then find each line that has '$' on the line and keep it
# so I can use it
i = {}
for i in range(0,len(lines)):
string.find('Total')<= 0
string.find('$')>= 0
# # end of processFile() function #
# write the results to the new file
out_file.writelines(lines)
out_file.close()
in_file.close()
# ---------------------------------------------------
Traceback (innermost last):
File "question1.py", line 25, in ?
string.find('Total')<= 0
TypeError: function requires at least 2 arguments; 1 given
Are there any examples of how this can be accomplished?
Why am I having sooooo.. much trouble?
Dan
---------------------------------------------------------------------------------------
| Daniel D. Laskey, CPA-------------------dlaskey@laskeycpa.com
| Daniel D. Laskey Company, P.C.------231-723-8305 Voice
| 231-723-6097 Fax
| Certified Public Accountants
| 507 Water Street
| Manistee, MI 49660
---------------------------------------------------------------------------------------