<FONT size=2>

<div>Hi;</div>


<div>I'm trying to edit MS Word tables with a python script. Here's a snippet:</div>


<div>import string</div>


<div>def msw2htmlTables():</div>


<div>input = "/usr/home/me/test.doc"</div>


<div>input = open(input,'r')</div>


<div>word = "whatever"</div>


<div>inputFlag = 0</div>


<div>splitString = []</div>


<div>for line in input:</div>


<div># Check first the inputFlag, since we only want to delete the top</div>


<div>if inputFlag == 0:</div>


<div>splitString = line.split(word)</div>


<div>try:</div>


<div>keep = splitString[1]</div>


<div>except:</div>


<div>keep = "nada"</div>


<div>print len(splitString)</div>


<div>inputFlag = 1</div>


<div>elif inputFlag == 1:</div>


<div># This means we've deleted the top junk. Let's search for the bottom junk.</div>


<div>splitString = line.split(word)</div>


<div>try:</div>


<div>keep = splitString[0]</div>


<div>inputFlag = 2</div>


<div>print len(splitString)</div>


<div>except:</div>


<div>keep += line</div>


<div>elif inputFlag == 2:</div>


<div># This means everything else is junk.</div>


<div>pass</div>


<div>Now, if var "word" is "orange", it will never pring the length of splitString. If it's "dark", it will. The only difference is the way they appear in the document. "orange" appears with a space character to the left and some MS garbage character to the right, while "dark" appears with a space character to the left and a comma to the right. Furthermore, if I use MSW junk characters as the definition of "word" (such as " Ù ", which is what I really need to search), it never even compiles (complains of an unpaired quote). It appears that python doesn't like MSW's junk characters. What shall I do?</div>


<div>TIA,</div>


<div>Tony</div>
</FONT><div class="AOLPromoFooter">
<hr style="margin-top:10px;" />
Email and AIM finally together. You've gotta check out free <a href="http://o.aolcdn.com/cdn.webmail.aol.com/mailtour/aol/en-us/index.htm?ncid=AOLAOF00020000000970" target="_blank">AOL Mail</a>!<br/>
</div>