Line.Replace - Attribute error

Joined
Jan 18, 2012
Messages
3
Reaction score
0
Hi,

I am trying to replace spaces with underscores in a header record.
At this time I am only printing so I can see the results. When I get it to work I will write.
I am getting an attribute error on the line.replace.
Any ideas?

import csv
infile = open("fileexchange_response_12458229.csv", "r")
reader = csv.reader(infile)
record_cntr = 0
for line in reader:
if record_cntr == 0: #header line
print line # orig header line
line = line.replace(" ", "_") # replace spaces w/underscores
print line # header line fixed
record_cntr += 1
elif record_cntr <> 0 : #detail
print line
record_cntr += 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top