May-03-2017, 11:45 PM
I found the solution - the real issue is that the file had 'smart quotes' in it, not just straight quotes. Finally narrowed it down to that, and the below code with the smart quote in the replace argument worked. Thanks for the replies.
import os mypath = 'C:\\csv\\' myoutputpath = 'C:\\csv\\output\\' for file in os.listdir(mypath): # This will loop through every file in the folder if '.csv' in file: # Check if it's a csv file fpath = os.path.join(mypath, file) fpath_out = os.path.join(myoutputpath, file) #+ '_output' # Create an output file with a similar name to the input file with open(fpath) as infile: lines = infile.readlines() # Read all lines with open(fpath_out, 'w') as outfile: for line in lines: # One line at a time outfile.write(line.replace(u'\u201d', ''))# Remove each " and write the line infile.close() outfile.close()