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


Groups > comp.lang.python > #48011 > unrolled thread

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

Started bybuford.lumbar@gmail.com
First post2013-06-13 12:28 -0700
Last post2013-06-14 08:02 -0700
Articles 12 — 10 participants

Back to article view | Back to comp.lang.python


Contents

  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

#48011 — Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

Frombuford.lumbar@gmail.com
Date2013-06-13 12:28 -0700
SubjectCreating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program
Message-ID<34b25d59-63b8-44e7-ac10-0afc52a7d726@googlegroups.com>
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:

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...

Please, please help me my wrist is starting to hurt a lot. You would have my greatest appreciation for your help!

thank you, Buford

[toc] | [next] | [standalone]


#48013

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-06-13 15:41 -0400
Message-ID<mailman.3217.1371152487.3114.python-list@python.org>
In reply to#48011

[Multipart message — attachments visible in raw view] — view raw

there is a python module that reads and writes to excel files.  look for
that


On Thu, Jun 13, 2013 at 3: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:
>
> 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...
>
> Please, please help me my wrist is starting to hurt a lot. You would have
> my greatest appreciation for your help!
>
> thank you, Buford
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#48015

Frombuford.lumbar@gmail.com
Date2013-06-13 13:18 -0700
Message-ID<7fb1303f-51ad-47ee-bd7c-3d5646eee532@googlegroups.com>
In reply to#48013
On Thursday, June 13, 2013 3:41:24 PM UTC-4, Joel Goldstick wrote:
> there is a python module that reads and writes to excel files.  look for that
> 
> 
> 
> 
> On Thu, Jun 13, 2013 at 3:28 PM,  <buford...@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:
> 
> 
> 
> 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...
> 
> 
> 
> Please, please help me my wrist is starting to hurt a lot. You would have my greatest appreciation for your help!
> 
> 
> 
> thank you, Buford
> 
> --
> 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> 
> -- 
> 
> 
> Joel Goldstick
> http://joelgoldstick.com

Thank you

[toc] | [prev] | [next] | [standalone]


#48014

FromDave Angel <davea@davea.name>
Date2013-06-13 16:08 -0400
Message-ID<mailman.3218.1371154136.3114.python-list@python.org>
In reply to#48011
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

[toc] | [prev] | [next] | [standalone]


#48019

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-06-13 14:42 -0600
Message-ID<mailman.3221.1371156205.3114.python-list@python.org>
In reply to#48011
On Thu, Jun 13, 2013 at 1:41 PM, Joel Goldstick
<joel.goldstick@gmail.com> wrote:
> there is a python module that reads and writes to excel files.  look for
> that

More than one, actually, and which to use depends on whether "Excel
files" means the .xls or .xlsx format.  On Windows, the most flexible
solution is going to be to just use COM to control the Excel
application in reading and writing the files.  Outside of Windows, the
best bet is usually to work with csv files instead, as Dave suggested.

[toc] | [prev] | [next] | [standalone]


#48024

FromNick Cash <nick.cash@npcinternational.com>
Date2013-06-13 21:10 +0000
Message-ID<mailman.3225.1371158741.3114.python-list@python.org>
In reply to#48011
>> there is a python module that reads and writes to excel files.  look 
>> for that

>More than one, actually, and which to use depends on whether "Excel files" means the .xls or .xlsx 
>format.  On Windows, the most flexible solution is going to be to just use COM to control the Excel >application in reading and writing the files.  Outside of Windows, the best bet is usually to work >with csv files instead, as Dave suggested.

I've had success with the xlrd and xlwt suite of modules (http://www.python-excel.org/), using both .xls and .xlsx, on Linux. 

-Nick Cash

[toc] | [prev] | [next] | [standalone]


#48137

FromNeil Cerutti <neilc@norwich.edu>
Date2013-06-14 12:50 +0000
Message-ID<b20hsfFqkiqU1@mid.individual.net>
In reply to#48024
On 2013-06-13, Nick Cash <nick.cash@npcinternational.com> wrote:
>>> there is a python module that reads and writes to excel files.  look 
>>> for that
>
>>More than one, actually, and which to use depends on whether
>>"Excel files" means the .xls or .xlsx format.  On Windows, the
>>most flexible solution is going to be to just use COM to
>>control the Excel >application in reading and writing the
>>files.  Outside of Windows, the best bet is usually to work
>>>with csv files instead, as Dave suggested.
>
> I've had success with the xlrd and xlwt suite of modules
> (http://www.python-excel.org/), using both .xls and .xlsx, on
> Linux. 

I use xlrd for .xlsx on Windows with Office 2007, no problems.

I wouldn't call it convenient, though. It saves a coworker from
doing an export which seems worth it, but using csv.DictReader
is, much, much simpler. Unless there's some non-trivial need to
use Excel directly I strongly recommend exporting as csv and
using the csv module.

-- 
Neil Cerutti

[toc] | [prev] | [next] | [standalone]


#48052

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-06-14 03:02 +0000
Message-ID<51ba87ab$0$29997$c3e8da3$5496439d@news.astraweb.com>
In reply to#48011
On Thu, 13 Jun 2013 12:28:09 -0700, buford.lumbar 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:
[snip directions]

Cannot be done. What you describe is not "simple", and it certainly is 
not "super simple" like you have in your subject line. It will take, 
probably, tens of thousands of lines of code.

Fortunately, most of that work will already have been done, but there 
will probably be dozens, or maybe even a hundred or two, lines of code 
needed to glue all the pieces together.

Still want to do this?


> Please, please help me my wrist is starting to hurt a lot.

To much information!

You need to do more programming and less choking the chicken.

*wink*



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#48151

Frombuford.lumbar@gmail.com
Date2013-06-14 07:03 -0700
Message-ID<c4a63402-4351-4def-a66f-8cb3bccf9cba@googlegroups.com>
In reply to#48052
On Thursday, June 13, 2013 11:02:03 PM UTC-4, Steven D'Aprano wrote:
> On Thu, 13 Jun 2013 12:28:09 -0700, buford.lumbar 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:
> 
> [snip directions]
> 
> 
> 
> Cannot be done. What you describe is not "simple", and it certainly is 
> 
> not "super simple" like you have in your subject line. It will take, 
> 
> probably, tens of thousands of lines of code.
> 
> 
> 
> Fortunately, most of that work will already have been done, but there 
> 
> will probably be dozens, or maybe even a hundred or two, lines of code 
> 
> needed to glue all the pieces together.
> 
> 
> 
> Still want to do this?
> 
> 
> 
> 
> 
> > Please, please help me my wrist is starting to hurt a lot.
> 
> 
> 
> To much information!
> 
> 
> 
> You need to do more programming and less choking the chicken.
> 
> 
> 
> *wink*
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Thank you for your help and sense of humor... all the best, Buford

[toc] | [prev] | [next] | [standalone]


#48060

Fromrusi <rustompmody@gmail.com>
Date2013-06-13 21:43 -0700
Message-ID<5add38f3-df49-4355-a27b-ba6bc8d4d562@v10g2000pbv.googlegroups.com>
In reply to#48011
On Jun 14, 12:28 am, buford.lum...@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:
>
> 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...
>
1> will probably be best done inside excel. Simple export as Dave
suggests or something more programmer-ish like an excel macro to
export a specific column of links as a text-file

2> I am not clear about -- looked at the page and there were a number
of hits for 'population'
If the format is fixed -- same site different cities -- use beautiful
soup (in python) with urls from 1>

> Please, please help me my wrist is starting to hurt a lot. You would have my greatest appreciation for your help!
>
> thank you, Buford

[toc] | [prev] | [next] | [standalone]


#48119

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-06-14 11:48 +0000
Message-ID<kpevul$r22$2@dont-email.me>
In reply to#48011
On Thu, 13 Jun 2013 12:28:09 -0700, buford.lumbar 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:
> 
> 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.

Why do you want to do this in python? I thought visual basic (or a 
variant thereof) was the preferred coding environment for such things in 
ms office?

A quick google finds me vb code to download a url into a string - 
presumably once you've done that you can find the value you want to 
scrape into your spreadsheet.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#48159

FromMichael Herman <hermanmu@gmail.com>
Date2013-06-14 08:02 -0700
Message-ID<mailman.3311.1371222176.3114.python-list@python.org>
In reply to#48011
Hi there -

Yes, as others have said, this is not an easy project. That said, it
can be down. I'd use a combination of DataNitro, to connect with
Excel, and Scrapy, to easily scrap and crawl the sites. I'm adept at
both and would be happy to help you with this. Email me at
michael@mherman.org for help.

Best,

Michael

On Thu, Jun 13, 2013 at 12: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:
>
> 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...
>
> Please, please help me my wrist is starting to hurt a lot. You would have
> my greatest appreciation for your help!
>
> thank you, Buford
> --
> http://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web