You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
print("📥 جاري قراءة ملف JSON...")
with open("contacts.json", encoding="utf-8") as json_file:
data = json.load(json_file)
print("✅ تم تحميل بيانات JSON بنجاح.")
print("📤 جاري تحويل البيانات إلى ملف CSV...")
with open("contacts.csv", "w", newline="", encoding="utf-8") as csv_file:
fieldnames = ["Name", "Phone"]
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
for contact in data["contacts"]["list"]:
name = (f"{contact['first_name']} {contact['last_name']}").strip()
phone = contact["phone_number"]
writer.writerow({"Name": name, "Phone": phone})
print("✅ تم تصدير البيانات إلى ملف contacts.csv بنجاح!")
except FileNotFoundError:
print("❌ لم يتم العثور على ملف JSON. تأكد من وجود الملف.")
except KeyError as e:
print(f"❌ خطأ في البيانات: المفتاح {e} غير موجود.")
except json.JSONDecodeError:
print("❌ ملف JSON غير صالح أو يحتوي على خطأ.")
except Exception as e:
print(f"❌ حدث خطأ غير متوقع: {e}")
The text was updated successfully, but these errors were encountered:
There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!
import json
import csv
try:
print("📥 جاري قراءة ملف JSON...")
with open("contacts.json", encoding="utf-8") as json_file:
data = json.load(json_file)
print("✅ تم تحميل بيانات JSON بنجاح.")
except FileNotFoundError:
print("❌ لم يتم العثور على ملف JSON. تأكد من وجود الملف.")
except KeyError as e:
print(f"❌ خطأ في البيانات: المفتاح {e} غير موجود.")
except json.JSONDecodeError:
print("❌ ملف JSON غير صالح أو يحتوي على خطأ.")
except Exception as e:
print(f"❌ حدث خطأ غير متوقع: {e}")
The text was updated successfully, but these errors were encountered: