Script to convert comma delimited .txt files to Excel

Study group dedicated to learning how to code in the Python language.

Moderators: snarkout, Patrick, dann

Post Reply
User avatar
Patrick
Site Admin
Posts: 2519
Joined: Tue Apr 27, 2004 11:38 am
Location: Easton, PA
Contact:

Script to convert comma delimited .txt files to Excel

Post by Patrick » Fri Oct 31, 2008 7:41 am

Code: Select all

import csv,sys
filein = raw_input("Enter the input file name: ")
fileout = raw_input("Enter the output file name: ")
 
fin = open(filein, 'rb')     
fout = open(fileout, 'wb')  

reader = csv.reader(fin)
writer = csv.writer(fout, dialect='excel-tab')

for row in reader:
   writer.writerow(row)
 
fin.close()
fout.close()
Ego contemno licentia

Post Reply