Verileri tolist()
ile listeye çevirdiğin için olabilir mi?
.dropna().tolist()
bu kodu neden yazdın anlayamadım.
Örnek dosyanın 2 kopyasını alarak içeriklerinde ufak değişikkler yaptım ve aşağıdaki kod ile verileri tek dosyada topladım. Aslında sen zaten kodun çooook büyük kısmını yazmışsın. Hatta fazla kod yazmışşsın
import os
import pandas as pd
# Sonuçları saklayacak DataFrame oluştur
result_df = pd.DataFrame(columns=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ'])
# Çalışma dizini (current directory) içindeki Excel dosyalarını al
excel_files = [f for f in os.listdir() if f.endswith('.xlsm')]
# Her Excel dosyasını işle
for excel_file in excel_files:
try:
# Excel dosyasını oku
df = pd.read_excel(excel_file, header=None, engine='openpyxl')
# Belirtilen hücreleri al ve sonuç DataFrame'e ekle
result_df = result_df._append({
'A': df.iloc[18, 3],
'B': df.iloc[19, 3],
'C': df.iloc[20, 3],
'D': df.iloc[20, 4],
'E': df.iloc[21, 3],
'F': df.iloc[22, 3],
'G': df.iloc[23, 3],
'H': df.iloc[23, 7],
'I': df.iloc[24, 3],
'J': df.iloc[25, 3],
'K': df.iloc[26, 3],
'L': df.iloc[27, 3],
'M': df.iloc[28, 1],
'N': df.iloc[36, 2],
'O': df.iloc[37, 2],
'P': df.iloc[36, 9],
'Q': df.iloc[52, 5],
'R': df.iloc[55, 5],
'S': df.iloc[60, 5],
'T': df.iloc[61, 5],
'U': df.iloc[62, 5],
'V': df.iloc[63, 5],
'W': df.iloc[72, 6],
'X': df.iloc[74, 6],
'Y': df.iloc[76, 6],
'Z': df.iloc[79, 1],
'AA': df.iloc[80, 1],
'AB': df.iloc[83, 1],
'AC': df.iloc[84, 1],
'AD': df.iloc[104, 4],
'AE': df.iloc[105, 4],
'AF': df.iloc[106, 4],
'AG': df.iloc[108, 4],
'AH': df.iloc[109, 4],
'AI': df.iloc[115, 1],
'AJ': df.iloc[121, 11],
}, ignore_index=True)
except Exception as e:
print(f"Hata: {e}")
# Sonuçları "Sonuc.xlsm" adlı bir Excel dosyasına kaydet
result_df.to_excel("Sonuc.xlsx", index=False, engine='openpyxl')