Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'assignment': 0.07; 'automate': 0.07; 'iterate': 0.09; 'subject:into': 0.09; 'whole,': 0.09; 'windows,': 0.09; '"some': 0.16; 'adjacent': 0.16; 'assignment?': 0.16; 'assignments.': 0.16; 'csv': 0.16; 'fetch': 0.16; 'hyperlink': 0.16; 'parts,': 0.16; 'received:74.208.4.195': 0.16; 'simple.': 0.16; 'subject: \n ': 0.16; 'substring': 0.16; 'throw': 0.16; 'component': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'later': 0.20; 'python?': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'earlier': 0.24; 'fairly': 0.24; 'file.': 0.24; 'web.': 0.26; 'excel': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'program,': 0.31; 'getting': 0.31; 'page.': 0.31; 'convince': 0.31; 'extract': 0.31; 'libraries': 0.31; 'probably': 0.32; 'supposed': 0.32; 'run': 0.32; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'except': 0.35; 'problem.': 0.35; 'something': 0.35; 'convert': 0.35; 'definition': 0.35; 'but': 0.35; 'version': 0.36; 'subject:Simple': 0.36; 'hi,': 0.36; 'e.g.': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'that,': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'number,': 0.60; 'simple,': 0.60; 'solve': 0.60; 'then,': 0.60; 'break': 0.61; 'new': 0.61; 'simple': 0.61; "you're": 0.61; 'back': 0.62; 'email addr:gmail.com': 0.63; 'show': 0.63; 'real': 0.63; 'happen': 0.63; 'valuable': 0.63; 'more': 0.64; 'different': 0.65; 'charset:windows-1252': 0.65; 'population': 0.68; 'received:74.208': 0.68; 'internet': 0.71; 'export': 0.74; 'day': 0.76; 'hand.': 0.84; 'proves': 0.84; 'hyperlinks': 0.91; 'on?': 0.91 Date: Thu, 13 Jun 2013 16:08:38 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program References: <34b25d59-63b8-44e7-ac10-0afc52a7d726@googlegroups.com> In-Reply-To: <34b25d59-63b8-44e7-ac10-0afc52a7d726@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:E+6hHHhmnYj2rmZQG5hGzzYA1RI1Tsrv+z1Q7G8A083 Jly5vnyrET3ZKzK+RBlzofyEDLynxaWKWNiC9Hd90nMpAYNOBP Ig+HnKQl64RAUJcdxTO1u6Nm3kMoDUx6SpUDjw2Buczjs4SVcc pDZ3u1QDxY5KNQffz5te9vtoEnNzhK71NQHuE9v/aNSdtHHJCV WKASTJhQ2Axw9WzC0Q8K/ri38Nl2B2lxKkZ3BwRczaCOZPpaaT xVUDf/Eo3lbDn4sjDnwH81P5SIqX2CogTNP2ugkSOPt4PJoaMh AwP4yPQ0esR4G6F3fsmHecpaVSQntcsvctUEWOnN6dZtj8E4g= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371154136 news.xs4all.nl 15919 [2001:888:2000:d::a6]:45186 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48014 On 06/13/2013 03:28 PM, buford.lumbar@gmail.com wrote: > Hi, I'm new to Python. Would someone be able to write me and/or to show me how to write a simple program that: Hi, welcome to Python, and to the Python-list It's NOT a simple program, except by a very constrained definition of simple. > > 1-follows a hyperlink from MS Excel to the internet (one of many links like this, http://www.zipdatamaps.com/76180, for e.g.) and then, > > 2-copies some data (a population number, e.g. 54195) and then, > > 3-pastes that data back into the same MS Excel spreadsheet, into the adjacent cell. > > ... and that’s it... row after row of hyperlinks all in one column... What's the real problem, or is it assignment? Do you have lots of repetitive data you want to fetch once a day from many websites? Do you have an assignment that constrains you to use Excel and Windows, and Python? Do you have a boss that likes innovation? Are you supposed to fetch the links from a live instance of Excel ? What version of Python, and what OS does this have to run on? If you break the problem into its component parts, SOME of them are fairly simple. If you try to solve the problem as a whole, it's not simple, unless you can just copy much of it from your textbook, or from earlier assignments. If this were my problem, I'd throw out Excel to begin with. If your hyperlinks happen to be in an excel spreadsheet, then export them, probably to a csv file. Do that by hand. If it later proves valuable to automate that, consider it a new problem. Similarly getting the data back into Excel -- just use csv files. So now you have a URL, and you want to get something from the web. You could use one of the urlib libraries to fetch the page. You're pretty vague about "some data" but you could use substring to extract some bytes from the page. You can use the csv module to load in the spreadsheet, and iterate through the rows. For each row, you could use the previous paragraph to convert the URL into some data. Then write the row back out, but to a different csv file. If you want anything more specific than that (and probably not from me), you'd have to get a lot more specific about your real requirements. And convince somebody that it's not homework. -- DaveA