שיתוף | המרת גיבוי אנשי קשר מMTK ל Q8
-
שלום וברכה
עקב צורך מסויין בהמרת גיבוי אנשי קשר מMTK ל Q8
יצרתי סקריפט קצר בAI
מצ"ב הקודimport re def convert_vcard_format(input_path, output_path): with open(input_path, 'r', encoding='utf-8') as f: content = f.read() # פיצול לכרטיסים אינדיבידואליים raw_cards = re.split(r'BEGIN:VCARD', content) converted_cards = [] for card in raw_cards: if not card.strip(): continue # חילוץ נתוני השם (N) וטיפול בקיפול שורות (Soft line breaks) name_match = re.search(r'N;.*?:;=?(.*?);;;', 'BEGIN:VCARD' + card, re.DOTALL) if name_match: # הסרת סימני קיפול שורות ורווחים מיותרים encoded_name = name_match.group(1).replace('=\n', '').replace('=\r\n', '').strip() if encoded_name.startswith('='): # תיקון למקרה שהערך התחיל בשורה חדשה encoded_name = encoded_name[1:] if encoded_name.startswith('=') and not encoded_name.startswith('=D7') else encoded_name else: encoded_name = "" # חילוץ מספרי טלפון phone_matches = re.findall(r'TEL;VOICE;CELL:(.*)', card) # בניית הכרטיס החדש במבנה המדויק new_card = "BEGIN:VCARD\r\nVERSION:2.1\r\n" if encoded_name: # שדה N עם פרמטרים בסדר הנכון new_card += f"N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;{encoded_name};;;\r\n" # הוספת שדה FN new_card += f"FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:{encoded_name}\r\n" # הוספת טלפונים בפורמט מקוצר for phone in phone_matches: new_card += f"TEL;CELL:{phone.strip()}\r\n" new_card += "END:VCARD" converted_cards.append(new_card) # כתיבה לקובץ חדש עם סיומות שורות מתאימות (CRLF) with open(output_path, 'w', encoding='utf-8', newline='') as f: f.write("\r\n".join(converted_cards) + "\r\n") # הרצת ההמרה convert_vcard_format('vcard.vcf', 'vcard_converted.vcf')צריך שהגיבוי הישן יהיה באותה תיקייה בשם vcard.vcf
בהצלחה
-
שלום וברכה
עקב צורך מסויין בהמרת גיבוי אנשי קשר מMTK ל Q8
יצרתי סקריפט קצר בAI
מצ"ב הקודimport re def convert_vcard_format(input_path, output_path): with open(input_path, 'r', encoding='utf-8') as f: content = f.read() # פיצול לכרטיסים אינדיבידואליים raw_cards = re.split(r'BEGIN:VCARD', content) converted_cards = [] for card in raw_cards: if not card.strip(): continue # חילוץ נתוני השם (N) וטיפול בקיפול שורות (Soft line breaks) name_match = re.search(r'N;.*?:;=?(.*?);;;', 'BEGIN:VCARD' + card, re.DOTALL) if name_match: # הסרת סימני קיפול שורות ורווחים מיותרים encoded_name = name_match.group(1).replace('=\n', '').replace('=\r\n', '').strip() if encoded_name.startswith('='): # תיקון למקרה שהערך התחיל בשורה חדשה encoded_name = encoded_name[1:] if encoded_name.startswith('=') and not encoded_name.startswith('=D7') else encoded_name else: encoded_name = "" # חילוץ מספרי טלפון phone_matches = re.findall(r'TEL;VOICE;CELL:(.*)', card) # בניית הכרטיס החדש במבנה המדויק new_card = "BEGIN:VCARD\r\nVERSION:2.1\r\n" if encoded_name: # שדה N עם פרמטרים בסדר הנכון new_card += f"N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;{encoded_name};;;\r\n" # הוספת שדה FN new_card += f"FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:{encoded_name}\r\n" # הוספת טלפונים בפורמט מקוצר for phone in phone_matches: new_card += f"TEL;CELL:{phone.strip()}\r\n" new_card += "END:VCARD" converted_cards.append(new_card) # כתיבה לקובץ חדש עם סיומות שורות מתאימות (CRLF) with open(output_path, 'w', encoding='utf-8', newline='') as f: f.write("\r\n".join(converted_cards) + "\r\n") # הרצת ההמרה convert_vcard_format('vcard.vcf', 'vcard_converted.vcf')צריך שהגיבוי הישן יהיה באותה תיקייה בשם vcard.vcf
בהצלחה
-
@דוד-יצחק שים לב שטיפול בquoted-printable זה לא תקני.
ולכן זה עלול לשבור שמות.
עדיף להשתמש בquopri.decodestring. -
ב בינוני התייחס לנושא זה
-
ב בינוני התייחס לנושא זה
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות