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


Groups > comp.lang.python > #6938

Re: How to import data from MySQL db into excel sheet -- Very Urgent

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kushal.kumaran@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'attributes': 0.05; '-0700': 0.07; 'width': 0.07; 'python': 0.08; 'csv': 0.09; 'fetch': 0.09; 'length.': 0.09; 'pm,': 0.10; 'examples': 0.12; 'wrote:': 0.14; 'defined': 0.14; 'bieber': 0.16; 'columns': 0.16; 'declaimed': 0.16; 'dumps': 0.16; 'email addr:ix.netcom.com': 0.16; 'equation.': 0.16; 'f.close()': 0.16; 'properly.': 0.16; 'subject:import': 0.16; 'them...': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'received:74.125.82.174': 0.16; 'received:mail- wy0-f174.google.com': 0.16; 'cc:addr:python-list': 0.17; 'importing': 0.19; 'header:In-Reply-To:1': 0.21; 'column': 0.22; 'thu,': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'module,': 0.23; 'fri,': 0.23; 'code': 0.24; 'subject: -- ': 0.25; 'url:home': 0.25; 'subject:data': 0.26; 'url:mailman': 0.26; 'script': 0.27; 'example': 0.27; 'sender:addr:gmail.com': 0.28; 'message-id:@mail.gmail.com': 0.28; 'lee': 0.29; 'import': 0.29; 'accommodate': 0.29; 'subject:How': 0.30; 'cc:addr:python.org': 0.30; 'url:listinfo': 0.30; 'module': 0.30; 'writer': 0.30; 'looks': 0.31; 'too': 0.33; 'file': 0.34; 'that,': 0.34; 'there': 0.35; 'purely': 0.35; 'using': 0.35; 'data.': 0.37; 'similar': 0.37; 'received:google.com': 0.37; 'change': 0.37; 'ways': 0.37; 'page': 0.37; 'url:python': 0.38; 'received:74.125.82': 0.38; 'received:74.125': 0.38; 'subject:from': 0.38; 'url:org': 0.38; 'data': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'called': 0.39; 'more': 0.60; 'below': 0.61; 'waiting': 0.61; 'according': 0.63; 'increase': 0.64; 'here': 0.66; 'subject:Urgent': 0.73; 'dennis': 0.77; 'objective': 0.77; 'subject:Very': 0.84; 'vba': 0.84; 'skip:d 50': 0.93; 'sheet': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=1BACvG6Na7+FMxKYop4hCxx/81atfJ2mYbx3TJKiMV8=; b=x6PNPf09SS6t383WpqbekiukTSms+v+sGhXFcA7fEhLc4lPzJyY69Jdbu/yp12AIWu RtH1+GeLaqZmlrilvn1KKX4y9Xam5/XqyPvQh0+oI9lMwvl4kUnrbsZ0+vjKZB6OqvU2 EyLQsWR7powZU/foN29DizhTWbgJ8R90y6QR8=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=LgMb6KYemAXo4xmhcFDWIeymgSlJBJqYVr+xrcRUHKRCk7H5ogeHXrogLLdkav+gyu XFCxpiwol0cFYJskS6H8u8nug1OxLHWDuHZy6kOOoLWAeyMJDDWcGNMdJBL+hJFaARS9 885/lLHf8enRojoO2I7pGNMVxw4S/ErxfuwwE=
MIME-Version 1.0
Sender kushal.kumaran@gmail.com
In-Reply-To <abce1ec7-2265-451f-ac5b-1a3aa79e3fae@22g2000prx.googlegroups.com>
References <9ad94241-e281-4325-9c0d-23547ad0b9b9@glegroupsg2000goo.googlegroups.com> <85318329-5bc8-4474-a54e-4e7ff53cd304@k3g2000prl.googlegroups.com> <mailman.2396.1307040552.9059.python-list@python.org> <abce1ec7-2265-451f-ac5b-1a3aa79e3fae@22g2000prx.googlegroups.com>
From Kushal Kumaran <kushal.kumaran+python@gmail.com>
Date Fri, 3 Jun 2011 18:11:21 +0530
X-Google-Sender-Auth rTQfy0NBmWt1Dte0WtHwiWDeFEY
Subject Re: How to import data from MySQL db into excel sheet -- Very Urgent
To hisan <santosh.ssit@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2428.1307104903.9059.python-list@python.org> (permalink)
Lines 87
NNTP-Posting-Host 82.94.164.166
X-Trace 1307104903 news.xs4all.nl 49048 [::ffff:82.94.164.166]:46570
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6938

Show key headers only | View raw


On Fri, Jun 3, 2011 at 5:52 PM, hisan <santosh.ssit@gmail.com> wrote:
> Task i need to achieve here is:
> I need to write a python script which fetches all the data from the
> MySQL database and dumps into an excel sheet. since i was not able to
> dump the data into excel sheet i used CSV file which looks similar to
> excel sheet.
> on dumping the data into CSV file i came know that column width is too
> small and hence it was not possible to display data properly.
> Hence i requested the way to increase the column widht to accommodate
> data of any length.
>

The xlwt module lets you write excel files from python.  There is more
information at http://www.python-excel.org/.  The examples page has an
example called col_width.py, which should be what you need.

> below is my sample code
>
>
> import os,time
> import MySQLdb
> import csv
> db=MySQLdb.Connect("localhost","root","san123","phone")
> cursor=db.cursor()
>
> cursor.execute("select column_name from information_schema.columns
> where table_name='phonebook'")
> row=cursor.fetchall()
> f=open(os.getcwd()+"\\analytics.csv",'w')
> writer = csv.writer(f)
> writer.writerow(row)
> cursor.execute("select * from phonebook")
> col_val=cursor.fetchall()
> writer.writerows(col_val)
> f.close()
>
> My Main objective is to fetch the data and from database and dump it
> into excel sheet or csv file using Python.
> If there any ways to achieve this using python please let me know.
>
> Waiting for the early response-
>
> I need to achieve my task using python only
>
>
>
>
>
>
> On Jun 2, 2:48 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
>> On Thu, 2 Jun 2011 10:25:24 -0700 (PDT), hisan <santosh.s...@gmail.com>
>> declaimed the following in gmane.comp.python.general:
>>
>>
>>
>> > Currently i am importing the Database into CSV file using csv module,
>> > in csv file i need to change the column width according the size of
>> > the data. i need to set different column width for different columns
>> > pleas let me know how to achieve this
>>
>>         Since CSV files are purely text, no Excel Spreadsheet visual
>> attributes can be defined in them...
>>
>>         Take Python out of the equation.
>>
>>         How would you change column width using an Excel VBA script/macro?
>>
>>         When you can answer that, you will have the answer of how to do it
>> from Python...
>> --
>>         Wulfraed                 Dennis Lee Bieber         AF6VN
>>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
regards,
kushal

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


Thread

Aw: How to import data from MySQL db into excel sheet Martin Brochhaus <martin.brochhaus@googlemail.com> - 2011-06-02 05:19 -0700
  Re: How to import data from MySQL db into excel sheet hisan <santosh.ssit@gmail.com> - 2011-06-02 10:25 -0700
    Re: How to import data from MySQL db into excel sheet Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-06-02 11:48 -0700
      Re: How to import data from MySQL db into excel sheet -- Very Urgent hisan <santosh.ssit@gmail.com> - 2011-06-03 05:22 -0700
        Re: How to import data from MySQL db into excel sheet -- Very Urgent Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2011-06-03 18:11 +0530
    RE: How to import data from MySQL db into excel sheet "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-06-06 12:35 -0400
    Re: How to import data from MySQL db into excel sheet Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-06 11:43 -0700
    RE: How to import data from MySQL db into excel sheet "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-06-06 16:18 -0400

csiph-web