MIF_E31231430/read_excel.py

26 lines
807 B
Python

import openpyxl
import pandas as pd
import os
def read_excel(file_path):
print(f"\n====================\nReading: {file_path}\n====================")
if not os.path.exists(file_path):
print("File not found")
return
try:
df = pd.read_excel(file_path)
print(df.head(25))
except Exception as e:
try:
wb = openpyxl.load_workbook(file_path, data_only=True)
sheet = wb.active
for r in range(1, 25):
row_vals = [sheet.cell(r, c).value for c in range(1, 10)]
if any(row_vals):
print(row_vals)
except Exception as ex:
print(f"Error: {ex}")
read_excel("../Dataset_TOPSIS_Rekomendasi_Kamera Fix.xlsx")
read_excel("perhitungan-topsis-outdoor-day.xlsx")