def ImportCSV(filename, post_url, cookie, batch_size, kind, split_url=SplitURL, openfile=file, create_content_generator=ContentGenerator, post_entities=PostEntities):
 (host_port, uri) = split_url(post_url)
 csv_file = openfile(filename, 'r')
 try:
  content_gen = create_content_generator(csv_file, batch_size)
  logging.info('Starting import; maximum %d entities per post', batch_size)
  for (num_entities, content) in content_gen:
   logging.info('Importing %d entities in %d bytes', num_entities, len(content))
   try:
    content = post_entities(host_port, uri, cookie, kind, content)
   except PostError as e:
    logging.error('An error occurred while importing: %s', e)
    return False
 finally:
  csv_file.close()
 return True

def ImportCSV ( filename , post_url , cookie , batch_size , kind , split_url = SplitURL , openfile = file , create_content_generator = ContentGenerator , post_entities = PostEntities ) : ( host_port , uri ) = split_url ( post_url ) csv_file = openfile ( filename , 'r' ) try : content_gen = create_content_generator ( csv_file , batch_size ) logging . info ( 'Starting import; maximum %d entities per post' , batch_size ) for ( num_entities , content ) in content_gen : logging . info ( 'Importing %d entities in %d bytes' , num_entities , len ( content ) ) try : content = post_entities ( host_port , uri , cookie , kind , content ) except PostError as e : logging . error ( 'An error occurred while importing: %s' , e ) return False finally : csv_file . close ( ) return True
imports csv data using a series of http posts .