View Full Version : Import CSV-List and fill UserData-Fields

02 February 2013, 12:41 PM
I am looking for a way to import a csv-file (with undefined number of rows) and set userdata of an Object with the values from the file.
The Userdata have to Change in dependency of a frame.

Is this possible?

Here a example of the csv-file:

Each "column" of csv-File contains a value of userdata:

C1, C2, C3, C4, C5
1, Name1, 100, 200, 50
2, Name2, 75, 100, 75
88, Testname , 180, 300, 200


Frame 1:
Userdata1: Name1
Userdata2: 100
Userdata3: 200
Userdata4: 50

Frame 2:
Userdata1: Name2
Userdata2: 75
Userdata3: 100
Userdata4: 75

Thank You!

02 February 2013, 07:02 PM
Hi jskw,

You can use the csv ( module to read in the file. You can set the userdata-field with ID 1
like op[c4d.ID_USERDATA, 1] = value.


02 February 2013, 09:52 PM
Hello Niklas,

thank you for your reply.

Is it possible to select a specific value from the csv-table?
for example:

row 2, column 3 = value5
Thank you

02 February 2013, 03:19 AM
a csv reader is just a 2d array, or in pythonish, is an iterator:

data = csv.reader(my_csv_string)

for row in data:
for cell in row:
print cell

so it would be value = data[row][cell].

02 February 2013, 04:33 PM
>>> a csv reader is just a 2d array, or in pythonish, is an iterator:

Not exactly. It is an iterator, but not a 2d array. You have to convert it before subcsripting,
eg. using a list-comprehension:

reader = csv.reader(open("foofile.csv"))
data = [row for row in reader]
print data[2][3]


02 February 2013, 08:41 PM
Here is a solution of my problem in a german forum!

Thank you Niklas!

Here is the Link:

CGTalk Moderation
02 February 2013, 08:41 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.