Bonjour à tous,

Je souhaite lire chaque feuille d'un fichier Excel et de mettre celles-ci dans un tableau respectif, c'est à dire feuille1 dans array1, etc...

J'utilise la bibliothèque xldr pour lire le dit fichier Excel.

J'exploite ce code trouvé sur le net mais il ne correspond pas exactement à mes attentes.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
import os
import xlrd
import numpy as np
import sys
 
#File to open
workbook = xlrd.open_workbook('mon_fichier.xls')
 
SheetNameList = workbook.sheet_names()
print(SheetNameList)
for i in np.arange(len(SheetNameList)):
    print(SheetNameList[i])
 
#Number of column and rows into sheet(0) here
worksheet = workbook.sheet_by_name(SheetNameList[0])
num_rows = worksheet.nrows 
num_cells = worksheet.ncols
 
 
num_rows=36
 
#Number of the first line to be read
curr_row = 1
while curr_row < num_rows:
    row = worksheet.row(curr_row)
    print (row, len(row), row[0], row[1])
    #print( 'Row: ', curr_row )
    #print( row, len(row), row[0] )
 
    curr_cell = 0
    while curr_cell < num_cells:
        #Cell Types: 0=Empty, 1=Text, 2=Number, 3=Date, 4=Boolean, 5=Error, 6=Blank
        cell_type = worksheet.cell_type(curr_row, curr_cell)
        if cell_type != 0:
            cell_value = worksheet.cell_value(curr_row, curr_cell)
            print(cell_value )
            curr_cell += 1
        else:
            curr_cell += 1
    curr_row += 1
Merci par avance pour vos conseils :-)