[Tutor] Loading and writing files

Daniel D. Laskey, CPA dlaskey@laskeycpa.com
Mon, 31 Jul 2000 15:42:52 -0400


#-----------Objective---------------------------------------
#  
#  1.  Open a file that is comma deiminated called test.csv 
#      and then print the file to the screen.
#      33.04,123196,12,421020,RVN# 179-Ernest Lonard,12528.7
#      33.04,123196,12,421020,RVN# 196-Hector Gale,2599.7
#      33.04,123196,12,421230,RVN# 249-Richard George,2300
#      33.04,123196,12,420000,Total Sales Journal,-17428.4
#
#  2.  Write the file to a file called junk2.txt and be able 
#      to "cat" or "type" the file after the program terminates.
#
#  3.  Read the data in the 5th position of the file and put " "s
#      around the data, so that the ending file lools like this:
#      33.04,123196,12,421020,"RVN# 179-Ernest Lonard",12528.7
#      33.04,123196,12,421020,"RVN# 196-Hector Gale",2599.7
#      33.04,123196,12,421230,"RVN# 249-Richard George",2300
#      33.04,123196,12,420000,"Total Sales Journal",-17428.4
#
#-----------My Code----------------------------------------------

import string 
import sys

print "Enter the name of the .CSV file to convert:"
in_file = raw_input(".CSV file name?  ")
in_file = open(x,"r")
text = in_file.read()
print text 
out_file = open("junk2.txt","w")
for line in in_file.readlines():
    out_file.write()
out_file.close()
in_file.close()

#-------------End of Code--------------------------------------------
#
#  Thanks in advance for your help.
#  Dan
#--------------------------------------------------------------------
# Daniel D. Laskey, CPA--------------------dlaskey@laskeycpa.com
# Daniel D. Laskey Company, P.C.-----231-723-8305  / Fax 231-723-6097
# Certified Public Accountants
# 507 Water Street
# Manistee, MI  49660
#--------------------------------------------------------------------