I'm trying to do template replacing in a file using pyratemp module. It's working fine with general ascii and UTF-8 format files. But, my file format is : "UTF-8 Unicode C program text, with CRLF line terminators"
I'm having some variable in sql to replace. So, I'm processing using pyratemp module as followed.
import pyratemp
data_hash = {}
data_hash['tab_name'] = 'svm_table'
sourceFile = "sample.sql"
temp_sql = pyratemp.Template(filename=sourceFile, data=data_hash, encoding='utf-8')
Running the script:
python template_proc.py
Traceback (most recent call last): File "template_proc.py", line 11, in print temp_sql UnicodeEncodeError: 'ascii' codec can't encode character u'\u503c' in position 196: ordinal not in range(128)
Can any-one suggest me the solution to do it.