On an Excel sheet I have a table with two columns (Date and Value). The date has the format dd/mm/yy
. With the script I show below I import the data contained in the A63:B80
range of said Excel sheet.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import openpyxl
# Abrir el archivo y almacenarlo en doc
doc = openpyxl.load_workbook('cotizaciones.xlsx')
# hojas disponibles
print doc.get_sheet_names()
# seleccionamos hoja para trabajar
hoja = doc.get_sheet_by_name('Sheet')
hoja.title
# seleccionar un rango
seleccion = hoja['A63':'B80']
dicc_cotiz = {}
for filas in seleccion:
for columnas in filas:
print columnas.value
With this iteration I can see the imported data, with this format:
2017-06-15 00:00:00
44.14
There are two problems that I now pose:
a) .- How could I create a dictionary with these data ?.
b) .- How could you change the format of the date, so that it was the key in the dictionary with the format 2017-06-15
, or better yet, 15/06/2017
?