Skip to content

Instantly share code, notes, and snippets.

@inazense
Created November 23, 2017 16:34
Show Gist options
  • Save inazense/f620394d1e8f8959fa0ed848f7af5508 to your computer and use it in GitHub Desktop.
Save inazense/f620394d1e8f8959fa0ed848f7af5508 to your computer and use it in GitHub Desktop.
Lector ficheros XLSX con Python3
# -*- coding: utf-8 -*-
from openpyxl import load_workbook # Requiere instalar openpyxl
import os.path
rutaXLSX = "fichero.xlsx"
if os.path.isfile(rutaXLSX):
libro = load_workbook(rutaXLSX) # Abro el excel para extraer los campos
hoja = libro.get_sheet_by_name(libro.get_sheet_names()[0]) # Cojo la primera hoja
for fila in hoja.rows:
for celda in fila:
print(celda.value)
else:
print("No se ha reconocido el fichero")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment