Search code examples
pythonxlrdxlwtxlutils

Is it possible to push data from Excel sheet using Python into a database?


I have a requirement where using Python I need to write into excel cell , the data which i will be collecting from web page.

But not getting an option how to do that.

any idea from you people?

As per @Marcin comments here is the more clear requirement I am looking for

Why is python a requirement? -> Yes I am using Python with Beautiful Soup module to fetch data from web page.

Where is excel running, or is it running at all? -> Excel is needed when a script would complete its data collection from the web page,and will take an attempt to the next page to do the same tasks,I want the current data to be saved into an excel format.

How is this related to the web? What exactly are you trying to achieve? Hope this answer is given to the above question of your.

Could you just work with a CSV file? Yes,I can work with it,but my final goal is to push the data back to an database,which could be an Oracle or Access database.

Architecture

                 ------------------
                |       web        |
                |       page       |
                 ------------------
                          |
                          |
                          |
            Python and BS4(Data Extraction)
                          |
                          |
                          |
                 ------------------                               
                |       Excel      |
                |       data       |
                 ------------------
                          |
                          |
                          |
             Python to Push Data(Oracle/Access)
                          |
                          |
                          |
                 ------------------
                |       Any        |
                |       DB         |
                 ------------------

EDIT

As per @Thang

I have tried but getting the error:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Happy>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named win32com.client
>>>

Solution

  • Give OpenPyXL a try if you are doing Office 2007 excel (aka xlsx files)