Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from reportlab.lib.pagesizes import letter
- from reportlab.platypus import Table, TableStyle, SimpleDocTemplate, Paragraph
- from reportlab.lib import colors
- from reportlab.lib.units import inch
- from reportlab.lib.styles import getSampleStyleSheet
- import tkinter as tk
- from tkinter import filedialog, messagebox
- def import_contacts_csv(csv_path):
- df = pd.read_csv(csv_path)
- first = df.get('First Name', pd.Series([''] * len(df))).astype(str)
- last = df.get('Last Name', pd.Series([''] * len(df))).astype(str)
- phone1 = df.get('Phone 1 - Value', pd.Series([''] * len(df))).astype(str)
- phone2 = df.get('Phone 2 - Value', pd.Series([''] * len(df))).astype(str)
- email = df.get('E-mail 1 - Value', pd.Series([''] * len(df))).astype(str)
- po_box = df.get('Address 1 - PO Box', pd.Series([''] * len(df))).astype(str)
- street = df.get('Address 1 - Street', pd.Series([''] * len(df))).astype(str)
- city = df.get('Address 1 - City', pd.Series([''] * len(df))).astype(str)
- region = df.get('Address 1 - Region', pd.Series([''] * len(df))).astype(str)
- postal_raw = df.get('Address 1 - Postal Code', pd.Series([''] * len(df)))
- def clean_field(val):
- s = str(val).strip()
- if s.lower() == 'nan':
- return ''
- return s
- def clean_postal(val):
- s = clean_field(val)
- # Remove trailing .0 if present (from float conversion)
- if s.endswith('.0') and s.replace('.0', '').isdigit():
- return s[:-2]
- return s
- # Clean all fields
- first = first.apply(clean_field)
- last = last.apply(clean_field)
- phone1 = phone1.apply(clean_field)
- phone2 = phone2.apply(clean_field)
- email = email.apply(clean_field)
- po_box = po_box.apply(clean_field)
- street = street.apply(clean_field)
- city = city.apply(clean_field)
- region = region.apply(clean_field)
- postal = postal_raw.apply(clean_postal)
- # Combine address fields, skipping empty parts
- address = [', '.join(filter(None, [str(po).strip(), str(st).strip(), str(ci).strip(), str(re).strip(), str(pc).strip()])) for po, st, ci, re, pc in zip(po_box, street, city, region, postal)]
- import re
- def phone_link(label, number):
- num = str(number).strip()
- if not num:
- return ''
- digits = re.sub(r'[^0-9+]', '', num)
- if digits:
- return f'{label}: <link href="tel:{digits}">{num}</link>'
- else:
- return f'{label}: {num}'
- phones = []
- for p1, p2 in zip(phone1, phone2):
- phone_parts = []
- if str(p1).strip():
- phone_parts.append(phone_link("Phone 1", p1))
- if str(p2).strip():
- phone_parts.append(phone_link("Phone 2", p2))
- phones.append("<br/>".join(phone_parts))
- contacts = list(zip(first, last, phones, email, address))
- return contacts
- def export_contacts_to_pdf(contacts, pdf_path):
- doc = SimpleDocTemplate(pdf_path, pagesize=letter)
- elements = []
- data = [["First Name", "Last Name", "Phone(s)", "Email", "Address"]]
- styles = getSampleStyleSheet()
- for c in contacts:
- from reportlab.lib.styles import ParagraphStyle
- wrap_style = ParagraphStyle('wrap', parent=styles['Normal'], wordWrap='CJK', allowOrphans=1, allowWidows=1, splitLongWords=True, fontSize=8, leading=10)
- row = [
- Paragraph(str(c[0]), wrap_style), # First Name
- Paragraph(str(c[1]), wrap_style), # Last Name
- Paragraph(str(c[2]), wrap_style), # Phone(s) clickable, new lines
- Paragraph(str(c[3]), wrap_style), # Email
- Paragraph(str(c[4]), wrap_style) # Address
- ]
- data.append(row)
- table_data = [data[0]]
- for row in data[1:]:
- table_data.append([row[0], row[1], row[2], row[3], row[4]])
- table = Table(table_data, repeatRows=1, colWidths=[1.1*inch, 1.1*inch, 1.7*inch, 1.7*inch, 2.2*inch])
- table.setStyle(TableStyle([
- ('BACKGROUND', (0,0), (-1,0), colors.lightblue),
- ('TEXTCOLOR', (0,0), (-1,0), colors.whitesmoke),
- ('ALIGN', (0,0), (-1,-1), 'LEFT'),
- ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
- ('BOTTOMPADDING', (0,0), (-1,0), 12),
- ('GRID', (0,0), (-1,-1), 0.5, colors.grey),
- ('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
- ('WORDWRAP', (0, 0), (-1, -1), 'CJK'),
- ('VALIGN', (0, 0), (-1, -1), 'TOP'),
- ('SPLITLONGWORDS', (0, 0), (-1, -1), True),
- ]))
- style = TableStyle([
- ('BACKGROUND', (0,0), (-1,0), colors.lightblue),
- ('TEXTCOLOR', (0,0), (-1,0), colors.whitesmoke),
- ('ALIGN', (0,0), (-1,-1), 'LEFT'),
- ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
- ('BOTTOMPADDING', (0,0), (-1,0), 12),
- ('GRID', (0,0), (-1,-1), 0.5, colors.grey),
- ('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
- ])
- table.setStyle(style)
- elements.append(table)
- doc.build(elements)
- def run_gui():
- import os
- def browse_csv():
- path = filedialog.askopenfilename(filetypes=[('CSV Files', '*.csv'), ('All Files', '*.*')])
- if path:
- csv_entry.delete(0, tk.END)
- csv_entry.insert(0, path)
- # Set PDF path to same folder and base name as CSV
- base = os.path.splitext(os.path.basename(path))[0]
- folder = os.path.dirname(path)
- pdf_path = os.path.join(folder, base + '.pdf')
- pdf_entry.delete(0, tk.END)
- pdf_entry.insert(0, pdf_path)
- def browse_pdf():
- # Default to the folder of the CSV if available
- initialdir = os.path.dirname(csv_entry.get()) if csv_entry.get() else ''
- path = filedialog.asksaveasfilename(defaultextension='.pdf', filetypes=[('PDF Files', '*.pdf'), ('All Files', '*.*')], initialdir=initialdir)
- if path:
- pdf_entry.delete(0, tk.END)
- pdf_entry.insert(0, path)
- def export():
- csv_path = csv_entry.get().strip('"').strip("'")
- pdf_path = pdf_entry.get().strip('"').strip("'")
- if not pdf_path.lower().endswith('.pdf'):
- pdf_path += '.pdf'
- try:
- contacts = import_contacts_csv(csv_path)
- # messagebox.showinfo("Debug", f"Output PDF path: {pdf_path}\nNumber of contacts loaded: {len(contacts)}")
- export_contacts_to_pdf(contacts, pdf_path)
- messagebox.showinfo("Success", f"Exported {len(contacts)} contacts to {pdf_path}")
- except Exception as e:
- messagebox.showerror("Error", f"Failed to export PDF: {e}")
- root = tk.Tk()
- root.title("Contacts to PDF Exporter")
- tk.Label(root, text="Google Contacts CSV:").grid(row=0, column=0, sticky='e')
- csv_entry = tk.Entry(root, width=40)
- csv_entry.grid(row=0, column=1)
- tk.Button(root, text="Browse", command=browse_csv).grid(row=0, column=2)
- tk.Label(root, text="Output PDF file:").grid(row=1, column=0, sticky='e')
- pdf_entry = tk.Entry(root, width=40)
- pdf_entry.grid(row=1, column=1)
- # tk.Button(root, text="Browse", command=browse_pdf).grid(row=1, column=2)
- tk.Button(root, text="Export to PDF", command=export).grid(row=2, column=0, columnspan=3, pady=10)
- root.mainloop()
- if __name__ == "__main__":
- run_gui()
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=ikrqlmkwxy
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment