modified: excel_to_json.py
renamed: exel_datein/2024/06/Tagesbericht Beispiel.xlsx -> exel_datein/2024/06/13.xlsx new file: exel_datein/2024/09/4.xlsx
This commit is contained in:
@@ -4,24 +4,27 @@ import os
|
||||
import re
|
||||
|
||||
root_dir = "exel_datein"
|
||||
date_pattern = re.compile(r'(\d{4})[\\/](\d{2})')
|
||||
# Passe das Pattern an: Jahr/Monat/Tag
|
||||
date_pattern = re.compile(r'(\d{4})[\\/](\d{2})[\\/](\d{1,2})')
|
||||
|
||||
all_notes = []
|
||||
|
||||
for dirpath, _, filenames in os.walk(root_dir):
|
||||
match = date_pattern.search(dirpath)
|
||||
if not match:
|
||||
continue
|
||||
jahr, monat = match.groups()
|
||||
for filename in filenames:
|
||||
if filename.lower().endswith(('.xlsx', '.xls')):
|
||||
excel_path = os.path.join(dirpath, filename)
|
||||
# Versuche, Jahr, Monat und Tag aus dem Pfad zu extrahieren
|
||||
match = date_pattern.search(excel_path)
|
||||
if match:
|
||||
jahr, monat, tag = match.groups()
|
||||
else:
|
||||
jahr = monat = tag = "unbekannt"
|
||||
try:
|
||||
df = pd.read_excel(excel_path, sheet_name=0, usecols=[0, 1], names=["Kunde", "Info"])
|
||||
df = df.dropna(subset=["Kunde", "Info"])
|
||||
for _, row in df.iterrows():
|
||||
# Format: Kunde: Info (Jahr: xxxx, Monat: xx)
|
||||
note = f"{row['Kunde']}: {row['Info']} (Jahr: {jahr}, Monat: {monat})"
|
||||
# Format: Kunde: Info (Jahr: xxxx, Monat: xx, Tag: xx)
|
||||
note = f"{row['Kunde']}: {row['Info']} (Jahr: {jahr}, Monat: {monat}, Tag: {tag})"
|
||||
all_notes.append(note)
|
||||
print(f"Verarbeitet: {excel_path}")
|
||||
except Exception as e:
|
||||
|
||||
BIN
exel_datein/2024/09/4.xlsx
Normal file
BIN
exel_datein/2024/09/4.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user