On Thursday, September 12, 2013 6:01:20 PM UTC-5, stephen...@gmail.com wrote: > I have an excel file. When I select cells, copy from excel, and then use > win32clipboard to get the contents of the clipboard, I have a 131071 > character string. > > > > When I save the file as a text file, and use the python 3.3 open command to > read its contents, I only have 80684 characters. > > > > Excel (and other programs too) appends a bunch of b'\x00' (or similar) > characters. > > > > Is there a pythonic way to strip these out?
Odd behavior from excel. It seems as though the clipboard contents will vary according to the clipboard size. For example, in my 13 column row I select 2023 rows, copy to the clipboard, and def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return s s = getclipboard() len(s) gives me 16298. If I select one additional row, len(s) balloons to 32767. In the first case, s[-10:] is b'0.032573\r\n'. In the second case, s[-10:] is b'\x008\x008\x000\x005\x00\t' Does anyone know what is going on with that? -- https://mail.python.org/mailman/listinfo/python-list