Datos excel multiplicar columna por valor
Publicado por Walter Mardones (6 intervenciones) el 29/03/2023 01:26:59
Quiero que la tercer columna de ese archivo excel se multiplique por un valor (rel_esc) antes de que se cree la lista l1, alguién sabe como se puede hacer?. DESDE YA MUCHAS GRACIAS GENIOS!. Aclaración, soy un profano de la programación, lo que tengo lo hice copiando código de todas partes, así que si es paso a paso la explicación, mejor.
import openpyxl as oex
from tkinter import filedialog as fd
from tkinter.filedialog import askopenfilename
import pandas as pd
scalah = float(input("Escala horizontal: "))
print(f"La escala horizontal será 1/{escalah}")
escalav = float(input("Escala vertical: "))
print(f"La escala vertical será 1/{escalav}")
rel_esc = escalah / escalav
print(rel_esc)
wbook = oex.load_workbook(askopenfilename())
sh = wbook.active
l1 = []
for i in range(2, sh.max_row+1):
for j in range(2, sh.max_column+1):
cell = sh.cell(row=i, column=j)
l1.append(cell.value)
print(l1)
polygon = aDouble(l1)
print(polygon)
LA OTRA OPCIÓN ES QUE EN LOS DATOS DE POLYGON [0, 20, 0, 10, 25, 0, 20, 28, 0, 30, 30, 0, 40, 35, 0, 50, 44, 0, 60, 41, 0, 70, 40, 0, 80, 50, 0, 90, 25, 0, 100, 27, 0, 120, 26, 0, 130, 24, 0, 140, 20, 0] , EL SEGUNDO NÚMERO, EL CUARTO, EL SEXTO, ETC SE MULTIPLIQUEN POR rel_esc.
import openpyxl as oex
from tkinter import filedialog as fd
from tkinter.filedialog import askopenfilename
import pandas as pd
scalah = float(input("Escala horizontal: "))
print(f"La escala horizontal será 1/{escalah}")
escalav = float(input("Escala vertical: "))
print(f"La escala vertical será 1/{escalav}")
rel_esc = escalah / escalav
print(rel_esc)
wbook = oex.load_workbook(askopenfilename())
sh = wbook.active
l1 = []
for i in range(2, sh.max_row+1):
for j in range(2, sh.max_column+1):
cell = sh.cell(row=i, column=j)
l1.append(cell.value)
print(l1)
polygon = aDouble(l1)
print(polygon)
LA OTRA OPCIÓN ES QUE EN LOS DATOS DE POLYGON [0, 20, 0, 10, 25, 0, 20, 28, 0, 30, 30, 0, 40, 35, 0, 50, 44, 0, 60, 41, 0, 70, 40, 0, 80, 50, 0, 90, 25, 0, 100, 27, 0, 120, 26, 0, 130, 24, 0, 140, 20, 0] , EL SEGUNDO NÚMERO, EL CUARTO, EL SEXTO, ETC SE MULTIPLIQUEN POR rel_esc.
Valora esta pregunta


0