Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'rows': 0.09; 'strings.': 0.09; 'subject:characters': 0.09; 'python': 0.11; 'def': 0.12; 'columns': 0.16; 'experiments': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'length,': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject: \n ': 0.16; 'subject:windows': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'appears': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'copied': 0.24; 'helper': 0.24; 'visible': 0.24; 'file.': 0.24; 'code:': 0.26; 'excel': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'characters': 0.30; 'returned': 0.30; "i'm": 0.30; '(although': 0.31; 'stuff': 0.32; 'text': 0.33; 'subject:from': 0.34; 'subject:with': 0.35; 'info': 0.35; 'received:84': 0.35; 'there': 0.35; 'data,': 0.36; 'useful': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'email addr:gmail.com': 0.63; 'grab': 0.64; 'here': 0.66; 'header:Reply- To:1': 0.67; 'skip:w 40': 0.68; 'skip:w 30': 0.69; 'reply-to:no real name:2**0': 0.71; 'lack': 0.78; 'contents,': 0.84; 'reply- to:addr:python.org': 0.84; 'spreadsheet': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=cNrZ7DuN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=_yxm6v-lmbwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=4HBy_2rajJ0A:10 a=pGLkceISAAAA:8 a=E82MrWrWKwkb766jT5wA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Fri, 13 Sep 2013 02:56:53 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Stripping characters from windows clipboard with win32clipboard from excel References: <13c19665-6dc9-49fe-88c8-52c643892eba@googlegroups.com> <74479771-2726-4a34-8fd6-531d64c5b7a5@googlegroups.com> In-Reply-To: <74479771-2726-4a34-8fd6-531d64c5b7a5@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379037415 news.xs4all.nl 15865 [2001:888:2000:d::a6]:57323 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54093 On 13/09/2013 01:58, stephen.boulet@gmail.com wrote: > Hi Steven. Here is my code: > > import win32clipboard, win32con > > def getclipboard(): > win32clipboard.OpenClipboard() > s = win32clipboard.GetClipboardData(win32con.CF_TEXT) > win32clipboard.CloseClipboard() > return s > > I use this helper function to grab the text on the clipboard and do useful things with it. > > Sorry about the description; I have stuff to learn about strings and python 3.3. > > To get the string length, I just do len(s). There were 10 columns and 700+ rows of data, so len(s) returned 80684 from an excel spreadsheet saved as a text file. > >>From the clipboard contents copied from the spreadsheet, the characters s[:80684] were the visible cell contents, and s[80684:] all started with "b'\x0" and lack any useful info for what I'm trying to accomplish. > From my own experiments (although not with Excel) it appears that GetClipboardData returns bytes (a bytestring), not (Unicode) strings.