@sumone תחשוב על זה כמו קובץ csv, רק שהמפרידים הם לא פסיקים,
בכל שורה יש כותרת העמודה, # ואז הערך, כשבין עמודה לעמודה יש %

למזלך יש לי קוד קיים בפייתון שכתבתי פעם
import csv
import os
input_file = r"C:\Users\abaye\Downloads\LogFolderEnterExit-2024-04.ymgr"
output_folder = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(output_folder, "LogFolderEnterExit-2024-04.csv")
rows = []
all_field_names = set() # Collect all unique field names
def parse_line(line):
data = {}
parts = line.strip().split('%')
for part in parts:
if '#' in part:
key, value = part.split('#', 1)
data[key] = value
return data
# Read file and collect all fields from all rows
with open(input_file, "r", encoding="utf-8") as file:
for line in file:
data = parse_line(line)
rows.append(data)
all_field_names.update(data.keys())
field_names = sorted(list(all_field_names))
with open(output_file, "w", newline="", encoding="utf-8") as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=field_names)
writer.writeheader()
writer.writerows(rows)
print(f"CSV file saved as: {output_file}")
print(f"Found {len(field_names)} fields: {', '.join(field_names)}")
print(f"Processed {len(rows)} rows")