Facing Problems when reading a file from a zip file and writing it to another file
<p>I have wrirtten a python script which does the following:</p>

<p>1)It reads a journal file(.jrn) within a zip file from a particular path and writes the same to a text file on another path.</p>

<p>2) The text file is read by another python script(say x.py) to do some particular operations.</p>

<p>The problem im facing is, the text file which is written, though its contents are appearing same as in the journal file(which is read from zipfile), when it is read by another python script say x.py, some special characters are read, causing the script to fail.</p>

<p>When the x.py script reads the original jrn file(in zip file), it is getting processed successfully..</p>

<p>I use python 2.4 version, so i cant be using extract() function of Zipfile library.</p>

<p>I just want the contents of text file which is written,to be exactly same as the contents of jrn file which is read from zip. pls help.</p>

<p>Code:</p>

<pre><code>fout = zipfile.ZipFile(os.path.join(Out_path_Afp,Out_Path_Afp_File),'r')
files = fout.namelist()
dir = filter(lambda x:os.path.splitext(string.lower(x))[1]=='.jrn',files)
out_zip_files_pdf = re.compile('WW_'+Input_file_name+'_Restsoe_toload_prod.jrn')
pdf_jrn_list = filter(lambda x:out_zip_files_pdf.match(x),files)
for pdf_jrn_ls in pdf_jrn_list:
    pdf_jrn = pdf_jrn_ls    
print pdf_jrn
data_jrn_pdf = fout.read(pdf_jrn)
txt_outpath = "e:\\senthil\\log_recon\\jrn\\"
txt_outfile_pdf = time.strftime("%Y%m%d_%H%M",LocalTime)+'WW_'+Input_file_name+'_Restsoe_toload_prod.txt'

Output_Ptr_pdf = open(txt_outpath + txt_outfile_pdf,'w')
Output_Ptr_pdf.write(data_jrn_pdf)
Output_Ptr_pdf.close()
</code></pre>
