<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        font-size:8.0pt;
        font-family:Verdana;}
h1
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:21.6pt;
        text-indent:-21.6pt;
        page-break-after:avoid;
        font-size:12.0pt;
        font-family:Verdana;}
h2
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:28.8pt;
        text-indent:-28.8pt;
        page-break-after:avoid;
        font-size:10.0pt;
        font-family:Verdana;}
h3
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:63.0pt;
        text-indent:-36.0pt;
        page-break-after:avoid;
        font-size:9.0pt;
        font-family:Verdana;
        font-weight:normal;}
h4
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:43.2pt;
        text-indent:-43.2pt;
        page-break-after:avoid;
        font-size:14.0pt;
        font-family:"Times New Roman";}
h5
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:50.4pt;
        text-indent:-50.4pt;
        font-size:13.0pt;
        font-family:Verdana;
        font-style:italic;}
h6
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:57.6pt;
        text-indent:-57.6pt;
        font-size:11.0pt;
        font-family:"Times New Roman";}
p.MsoHeading7, li.MsoHeading7, div.MsoHeading7
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:64.8pt;
        text-indent:-64.8pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
p.MsoHeading8, li.MsoHeading8, div.MsoHeading8
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:72.0pt;
        text-indent:-72.0pt;
        font-size:12.0pt;
        font-family:"Times New Roman";
        font-style:italic;}
p.MsoHeading9, li.MsoHeading9, div.MsoHeading9
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:79.2pt;
        text-indent:-79.2pt;
        font-size:11.0pt;
        font-family:Arial;}
p.MsoNormalIndent, li.MsoNormalIndent, div.MsoNormalIndent
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:36.0pt;
        font-size:8.0pt;
        font-family:Verdana;}
p.MsoHeader, li.MsoHeader, div.MsoHeader
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        font-size:8.0pt;
        font-family:Verdana;}
p.MsoFooter, li.MsoFooter, div.MsoFooter
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        font-size:8.0pt;
        font-family:Verdana;}
p.MsoTitle, li.MsoTitle, div.MsoTitle
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        text-align:center;
        font-size:14.0pt;
        font-family:Verdana;
        font-weight:bold;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.Heading1bullet, li.Heading1bullet, div.Heading1bullet
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:63.0pt;
        text-indent:-18.0pt;
        page-break-after:avoid;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading1text, li.Heading1text, div.Heading1text
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:27.0pt;
        page-break-after:avoid;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading2text, li.Heading2text, div.Heading2text
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:27.0pt;
        page-break-after:avoid;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading2bullet, li.Heading2bullet, div.Heading2bullet
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:63.0pt;
        text-indent:-18.0pt;
        page-break-after:avoid;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading3text, li.Heading3text, div.Heading3text
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:26.95pt;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading3bullet, li.Heading3bullet, div.Heading3bullet
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:63.0pt;
        text-indent:-18.0pt;
        page-break-after:avoid;
        font-size:8.0pt;
        font-family:Verdana;}
p.Heading3Text0, li.Heading3Text0, div.Heading3Text0
        {margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:12.0pt;
        margin-left:70.9pt;
        text-align:justify;
        font-size:8.0pt;
        font-family:Verdana;}
span.EmailStyle29
        {font-family:Verdana;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
/* Page Definitions */
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
/* List Definitions */
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>I trying to process a file that was originally created on an AS/400 as
a spooled report. The file has been converted to ASCII before sending to me by
e-mail. The original report is in Arabic script and so any Arabic script has
been mapped to</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>I can’t read the whole file in unless I chop out all the (formerly)
Arabic characters as read(), readline() or readlines() seems to think its done
too early. The problem appears to be that the conversion has produced a byte with
hex value 1a and Python is treating this as an end-of-file marker. This I’ve
worked this out by using a Hex Editor and looking at the character after where
the read operation stops. The offending character the square (unprintable)
character in the file snippet below.</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>Start file snippet >></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>MK 2005/01/10 البنك العربي(ش .م.ع) الميزانية الموحدة - تقريـر
الميزانية الشهــرية كما هي في</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> 01 : فروع دولة امارات
========================================= الصـفحة
</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'><< End file snippet</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>Is there a way I can pre-process this file with Python and chop out the
characters ( the 1a) I don’t want?</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> </span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>If I do this:</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>import string</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>report =
open('d:\\Software\\PythonScripts\\ear11050110.txt').readlines()
</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>report is:</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>>>> report</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>['MK 2005/01/10 \xc7\xe1\xc8\xe4\xdf \xc7\xe1\xda\xd1\xc8\xed(\xd4
.\xe3.\xda) \xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9
\xc7\xe1\xe3\xe6\xcd\xcf\xc9 - \xca\xde\xd1\xed\xdc\xd1
\xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9 \xc7\xe1\xd4\xe5\xdc\xdc\xd1\xed\xc9 \xdf\xe3\xc7
\xe5\xed \xdd\xed\n', ' 01 : \xdd\xd1\xe6\xda \xcf\xe6\xe1\xc9
\xc7']</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> </span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>Which is everything up to the hex 1a.</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> </span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>Thanks for any prompting whatsoever.</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> </span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'>Nick.</span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-GB style='font-size:
10.0pt'> </span></font></p>
</div>
<FONT SIZE=3><BR>
<BR>
**********************************************************************<BR>
This email and any files transmitted with it are confidential and<BR>
intended solely for the use of the individual or entity to whom they<BR>
are addressed. If you have received this email in error please notify<BR>
the system manager.<BR>
This footnote also confirms that this email message has been swept by<BR>
MIMEsweeper for the presence of computer viruses.<BR>
Information Technology International (ITI) +44 (0)20 7315 8500<BR>
**********************************************************************<BR>
</FONT>
</body>
</html>