Import csv to Python syntax eludes me, what did I miss? I'm trying to import a list from a csv to create a series of circles.
I've created a few scripts that move and rotate objects with help of csv data, I used that csv routine as a template.
This time I wanted to create the object and thought I understood - for i, row in enumerate( rdr ): -
however, if you look at this snippet code, you might think I missed the boat completely.
My biggest problem at this moment is that I do not understand how I can get the csv values parsed correctly with add_circle().
Then I have a second issue regarding the fact that it only creates the first circle from the csv and I really thought that this would work.
Can somebody explain what I'm missing to make it work? Or does anybody know a comprehensive paper so I can figure out why this is not working as I expected.
with open( fp ) as csvfile:

# make series of circles
rdr = csv.reader( csvfile )
for i, row in enumerate( rdr ):
    if i == 0: continue # Skip column titles
    FRAME, PARTS, XW = row[0:3]
    part_number = float(PARTS)
    add_circle(FRAME, part_number, float(XW))

CSV snippet:
FRAME, PARTS, XW
1001,8,0
1002,15,1.1
1003B,32,2
etc.

In case the full script is more helpful:
# -*- coding: utf-8 -*-
&quot;&quot;&quot;
Name: 'Add cirkel'
Blender: 2.80
Group: 'Add'
Tooltip: 'Creates a shape object'
&quot;&quot;&quot;

import bpy, csv
import bpy.types
import time
from mathutils import *
import math

fp = &quot;C:/Users/Maarten/Documents/blender/csv/generate-object.csv&quot;


def object_from_data(data, name, scene, select=True):
    &quot;&quot;&quot; Create a mesh object and link it to a scene &quot;&quot;&quot;
    mesh = bpy.data.meshes.new(name)
    mesh.from_pydata(data['verts'], data['edges'], data['faces'])

    obj = bpy.data.objects.new(name, mesh)
    scene.collection.objects.link(obj)
    bpy.context.view_layer.objects.active = obj
    obj.select = True
    mesh.validate(verbose=True) 
    return obj

def vertex_circle(segments, z):
    &quot;&quot;&quot; Return a ring of vertices &quot;&quot;&quot;
    verts = []
    verts.append(( 0, 0, z))
    for j in range(segments):
        angle = (math.pi*2) * j / segments
        verts.append((math.cos(angle), math.sin(angle), z))
    return verts

def add_circle(name, segments, z):
    &quot;&quot;&quot; Make a circle &quot;&quot;&quot;

    data = {
    'verts': vertex_circle(segments, z),
    'edges': [],
    'faces': [],
    }
    data['faces'] = [(j, j+1, 0) for j in range(segments)]
    data['faces'].append((segments, 1, 0))

    scene = bpy.context.scene
    return object_from_data(data, name, scene)

with open( fp ) as csvfile:
    &quot;&quot;&quot; make series of circles &quot;&quot;&quot;
    rdr = csv.reader( csvfile )
    for i, row in enumerate( rdr ):
        if i == 0: continue # Skip column titles
        FRAME, PARTS, XW = row[0:3]
        add_circle(FRAME, 8, 0)

#        FRAME, PARTS, XW, YW, Z, EXP1, EXP2, WALL = row[0:8]
#        parts_number = float(PARTS)
#        add_circle(FRAME, 8, 0, 2, 0, 1, 2)
#        add_circle(FRAME, parts_number, 0, 2, 0, 1, 2)
#        if WALL == 1: add_circle2() else: add_circle()



FRAME,PARTS,XW,YW,Z,EXP1,EXP2,WALL
1001,8,0,2,0,1,2,0
1002,15,1,2,1,1,2,1
1003,32,2,3,2,1,2,1
1004,64,3,4,3,1,2,1
1005,128,4,5,4,1,2,0

The first is the script, the second the csv (please remove .txt extension before use)
In add_circle() I placed values PARTS=8 and XW=0. so the script creates one circle with only the name 1001 from CSV.
There were a couple of issues with the code.

The 'obj.select = True' line was referencing an invalid property of 'obj'. I've simply disabled that line.
I've put back in the commented out code in the last function to use the values extracted from the CSV. Note that the CSV data is returned as strings so each value needs 'casting' into the expected type - ie, to cast PARTS into an integer you can use `int(PARTS)'.

Here's my amended code - additionally implementing XW and YW for the width and depth of each circle (I changed the other functions to pass them through and use them in the calculation of the vertex position :
# -*- coding: utf-8 -*-
&quot;&quot;&quot;
Name: 'Add cirkel'
Blender: 2.80
Group: 'Add'
Tooltip: 'Creates a shape object'
&quot;&quot;&quot;

import bpy, csv
import bpy.types
import time
from mathutils import *
import math

fp = &quot;C:/Users/rich/Desktop/generate-object.csv&quot;


def object_from_data(data, name, scene, select=True):
    &quot;&quot;&quot; Create a mesh object and link it to a scene &quot;&quot;&quot;
    mesh = bpy.data.meshes.new(name)
    mesh.from_pydata(data['verts'], data['edges'], data['faces'])

    obj = bpy.data.objects.new(name, mesh)
    scene.collection.objects.link(obj)
    bpy.context.view_layer.objects.active = obj
    #obj.select = True
    mesh.validate(verbose=True) 
    return obj

def vertex_circle(segments, xw, yw, z):
    &quot;&quot;&quot; Return a ring of vertices &quot;&quot;&quot;
    verts = []
    verts.append(( 0, 0, z))
    for j in range(segments):
        angle = (math.pi*2) * j / segments
        verts.append((math.cos(angle)*xw, math.sin(angle)*yw, z))
    return verts

def add_circle(name, segments, xw, yw, z):
    &quot;&quot;&quot; Make a circle &quot;&quot;&quot;

    data = {
    'verts': vertex_circle(segments, xw, yw, z),
    'edges': [],
    'faces': [],
    }
    data['faces'] = [(j, j+1, 0) for j in range(segments)]
    data['faces'].append((segments, 1, 0))

    scene = bpy.context.scene
    return object_from_data(data, name, scene)

with open( fp ) as csvfile:
    &quot;&quot;&quot; make series of circles &quot;&quot;&quot;
    rdr = csv.reader( csvfile )
    for i, row in enumerate( rdr ):
        if i == 0: continue # Skip column titles
        #FRAME, PARTS, XW = row[0:3]
        #add_circle(FRAME, 8, 0)

        FRAME, PARTS, XW, YW, Z, EXP1, EXP2, WALL = row[0:8]
        parts_number = float(PARTS)
        #add_circle(FRAME, 8, 0, 2, 0, 1, 2)
        #add_circle(FRAME, parts_number, 0, 2, 0, 1, 2)
        #if WALL == 1: add_circle2() else: add_circle()
        add_circle(FRAME, int(PARTS), float(XW), float(YW), float(Z))

Here are the results from your sample CSV file (you need to amend the code to point at the location of the file if different to mine) :