469,282 Members | 1,715 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Import data from Excel

N/A
Hi,
Is it possible to import data from Excel for doing numerical analysis in
Python? If so how? Thank u!
May 10 '06 #1
4 3241
The CSV module?

May 10 '06 #2
N/A
sorry, can you say it more clearly?
In Matlab, I can easily import data from Excel just simply use 'xlsread'
command. How to do that in Python environment? thank u!

Paddy wrote:
The CSV module?

May 10 '06 #3
Try this:

from win32com.client import GetObject, constants

def GetExcelData(self, strFilePath):
""" Extract the data from the Excel sheet.
Returns tuple of tuples representing the rows and cells."""
# The following line extracts
# all the data from sheet 1 of the spreadsheet
return GetObject(strFilePath).Sheets(1).UsedRange.Value
N/A wrote:
Hi,
Is it possible to import data from Excel for doing numerical analysis in
Python? If so how? Thank u!


--
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk

May 10 '06 #4
Hi,
Is it possible to import data from Excel for
doing numerical analysis in Python? If so how?


use John Machins glamouros 'xlrd'
http://www.lexicon.net/sjmachin/xlrd.htm

form his documentation:

import xlrd
book = xlrd.open_workbook("myfile.xls")
print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols
print "Cell D30 is", sh.cell_value(rowx=29, colx=3)
for rx in range(sh.nrows):
print sh.row(rx)

This module is (imho) quite useful. No
need for installed Windows or Office.

Regards

Mirco
May 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Niklas | last post: by
2 posts views Thread by madeleine | last post: by
1 post views Thread by Eric | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.