Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48014

Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

Date 2013-06-13 16:08 -0400
From Dave Angel <davea@davea.name>
Subject Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program
References <34b25d59-63b8-44e7-ac10-0afc52a7d726@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3218.1371154136.3114.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program buford.lumbar@gmail.com - 2013-06-13 12:28 -0700
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Joel Goldstick <joel.goldstick@gmail.com> - 2013-06-13 15:41 -0400
    Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program buford.lumbar@gmail.com - 2013-06-13 13:18 -0700
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Dave Angel <davea@davea.name> - 2013-06-13 16:08 -0400
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-13 14:42 -0600
  RE: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Nick Cash <nick.cash@npcinternational.com> - 2013-06-13 21:10 +0000
    Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Neil Cerutti <neilc@norwich.edu> - 2013-06-14 12:50 +0000
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 03:02 +0000
    Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program buford.lumbar@gmail.com - 2013-06-14 07:03 -0700
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program rusi <rustompmody@gmail.com> - 2013-06-13 21:43 -0700
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-14 11:48 +0000
  Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program Michael Herman <hermanmu@gmail.com> - 2013-06-14 08:02 -0700

csiph-web