As you did not mention file format I will assume xlsx.
Making a pseudo-code in EAFP I imagine you can do something like that (as you didn’t mention, I imagine you’re not using any data analysis library like http://pandas.pydata.org/ for example) - as your data is scientific it is likely that a simple reading and iteration of tables will not suffice, however:
import xlrd
def open_file(caminho_de_arquivo):
"""
Definição da função que irá ler e criar no seu runtime a tabela equivalente
ao arquivo
"""
livro = xlrd.open_workbook(caminho_de_arquivo)
# exibir no console o número de planilhas
print livro.nsheets
# exibir o nome das planilhas
print livro.sheet_names()
# obter a primeira planilha, assinalando-a a uma variável local
primeira_planilha = book.sheet_by_index(0)
# exibir a primeira coluna da primeira planilha
print primeira_planilha.row_values(0)
# obter e exibir uma célula da primeira planilha
cell = primeira_planilha.cell(0,0)
print cell
print cell.value
# ler um slice de linha
print primeira_planilha.row_slice(rowx=0,
start_colx=0,
end_colx=2)
#----------------------------------------------------------------------
if __name__ == "__main__":
path = "caminho.xls"
open_file(path)with open('filepath.xlsx', 'r') as importer:
From this you can iterate on the spreadsheet as you want in a simple way:
cells = primeira_planilha.row_slice(rowx=0,
start_colx=0,
end_colx=2)
for cell in cells:
print cell.value
Tutorial removed and translated from post http://www.blog.pythonlibrary.org/2014/04/30/reading-excel-spreadsheets-with-python-and-xlrd/
Your question is a little vague, without objectivity. Have you thought about using the Numpy for that? Look at this "Quickstart": https://docs.scipy.org/doc/numpy-dev/user/quickstart.html
– stderr
How to send to python?
– guijob
In what format is this table?
– Pablo Almeida