parser = argparse.ArgumentParser(description="Import leads from CSV file") parser.add_argument("--api-key", "-k", required=True, help="API Key") parser.add_argument( "--skip_duplicates", action="store_true", help="Skip leads that are already present in Close.io (determined by company name).", ) parser.add_argument("--no_grouping", action="store_true", help="Turn off the default group-by-company behavior.") parser.add_argument("--development", action="store_true", help="Use a development server rather than production.") parser.add_argument("file", help="Path to the csv file") args = parser.parse_args() reader = CsvReader(args.file) header = reader.next() # skip the 1st line header import_count = count_lines(args.file) # may have no trailing newline cnt = success_cnt = 0 def warning(*objs): print("WARNING: ", *objs, file=sys.stderr) def slugify(str, separator="_"): str = unidecode.unidecode(str).lower().strip() return re.sub(r"\W+", separator, str).strip(separator)
parser = argparse.ArgumentParser( description='Remove email addresses from contacts in CSV file') parser.add_argument('--api-key', '-k', required=True, help='API Key') parser.add_argument('--confirmed', action='store_true', help='Really run this?') parser.add_argument('file', help='Path to the csv file') args = parser.parse_args() reader = CsvReader(args.file) headers = dict([( name, idx, ) for idx, name in enumerate(reader.next())]) # skip the 1st line header if any(field not in headers for field in ['contact_id', 'email_address']): print 'contact_id or email_address headers could not be found in your csv file.' sys.exit(-1) api = CloseIO_API(args.api_key, async=False) for row in reader: contact_id = row[headers['contact_id']] email_address = row[headers['email_address']] try: contact = api.get('contact/' + contact_id) if not contact['emails']: continue emails = filter(lambda email: email['email'] != email_address,
from progressbar.widgets import Percentage, Bar, ETA, FileTransferSpeed from requests.exceptions import ConnectionError from closeio_api import Client as CloseIO_API from closeio_api.utils import CsvReader, count_lines, title_case, uncamel parser = argparse.ArgumentParser(description='Import leads from CSV file') parser.add_argument('--api_key', '-k', required=True, help='API Key') parser.add_argument('--skip_duplicates', action='store_true', help='Skip leads that are already present in Close.io (determined by company name).') parser.add_argument('--no_grouping', action='store_true', help='Turn off the default group-by-company behavior.') parser.add_argument('--development', action='store_true', help='Use a development server rather than production.') parser.add_argument('file', help='Path to the csv file') args = parser.parse_args() reader = CsvReader(args.file) header = reader.next() # skip the 1st line header import_count = count_lines(args.file) # may have no trailing newline cnt = success_cnt = 0 def slugify(str, separator='_'): str = unidecode.unidecode(str).lower().strip() return re.sub(r'\W+', separator, str).strip(separator) # Look for headers/columns that match these, case-insensitive. All other headers will be treated as custom fields. expected_headers = ( 'company', # multiple contacts will be grouped if company names match 'url', 'status', 'contact', # name of contact
#!/usr/bin/env python import argparse, json, sys from requests.exceptions import ConnectionError from closeio_api import APIError, Client as CloseIO_API from closeio_api.utils import CsvReader parser = argparse.ArgumentParser(description='Remove email addresses from contacts in CSV file') parser.add_argument('--api-key', '-k', required=True, help='API Key') parser.add_argument('--confirmed', action='store_true', help='Really run this?') parser.add_argument('file', help='Path to the csv file') args = parser.parse_args() reader = CsvReader(args.file) headers = dict([(name, idx,) for idx, name in enumerate(reader.next())]) # skip the 1st line header if any(field not in headers for field in ['contact_id', 'email_address']): print 'contact_id or email_address headers could not be found in your csv file.' sys.exit(-1) api = CloseIO_API(args.api_key, async=False) for row in reader: contact_id = row[headers['contact_id']] email_address = row[headers['email_address']] try: contact = api.get('contact/' + contact_id) if not contact['emails']: continue emails = filter(lambda email: email['email'] != email_address, contact['emails'])