[Tutor] Trouble with encoding/decoding a file
tony.pelletier at gmail.com
Mon Feb 6 16:11:12 CET 2012
I've been tasked with getting the encoded value using a SOAP call and then
writing the file out. I first used the interpreter to do so like such:
encoded = 'super long encoded string'
data = base64.b64decode(encoded)
outfile = open('test.xls', 'w')
And that all worked just fine. The difference here is I am cutting and
pasting the encoded value into a string from notepad++.
So, I then did the following which I can't get working. It keeps telling
me "excel found unreadable content in the file' essentially being corrupt
and I can't tell what I'm doing wrong.
eventresult = service.client.service.EventQueryById(event, 'true')
filename = eventresult.Event.EventFileArgs.EventFileArg.UserFileName
encodedstring = encodedfile.encode('utf-8')
str_list = 
for line in encodedstring:
line = line.strip()
string = ''.join(str_list)
data = base64.b64decode(string)
txtfile = open('trp.txt', 'w')
outfile = open(filename, 'w')
except suds.WebFault as e:
The txt file is only there to make sure I'm writing out one long string
which is what I'm pasting in so I'm assuming that's correct. Any help is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor