Example #1
0
def import_csv(csv_filename):
    with open(csv_filename, mode='r') as csvfile:
        reader = csv.DictReader(csvfile)
        for row in reader:
            circle = Circle(**row)
            circle.save()
            print(circle.name)
Example #2
0
def load_data(csv_file):
    '''Load Circles Data from CSV File'''
    with open(csv_file, 'r') as csvfile:
        reader = csv.DictReader(csvfile)
        for row in reader:
            circle = Circle(**row)
            circle.save()
            print(circle.name)
Example #3
0
 def handle_import_csv(self, f):
     # For more information:
     # https://stackoverflow.com/questions/16243023/how-to-resolve-iterator-should-return-strings-not-bytes
     file = TextIOWrapper(f.file, encoding='utf-8')
     reader = csv.DictReader(file)
     for row in reader:
         circle = Circle(**row)
         circle.save()
Example #4
0
def load_circles(circles_csv_name):
	path = (environ.Path(__file__) - 3).path('dummy_data')
	os.chdir(path)
	with open(circles_csv_name) as circles_file:
		reader = csv.DictReader(circles_file)
		for row in reader:
			circle = Circle(
				name=row['name'],
				slug_name=row['slug_name'],
				is_public=row['is_public'],
				verified=row['verified'],
				members_limit=row['members_limit']
			)
			circle.save()
	print('Circles were loaded succesfully')
Example #5
0
def import_data(file):
    with open(file, 'r') as f:
        content = list(csv.reader(f))
        # print(f)
        for circle in content[1:]:
            Circle(name=circle[0],
                   slug_name=circle[1],
                   is_public=circle[2],
                   verified=circle[3],
                   members_limit=circle[4]).save()
Example #6
0
def import_csv(csv_filename):
    """ Function to load Circles through csv file """

    with open(csv_filename) as csvfile:
        reader = csv.DictReader(csvfile)
        for row in reader:
            circle = Circle(**row)
            if int(circle.members_limit) > 0:
                circle.is_limited = True
            else:
                circle.is_limited = False
            circle.save()
            print(circle.name)