Import CSV-List and fill UserData-Fields

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  02 February 2013
Import CSV-List and fill UserData-Fields

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
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.

Cinema 4D Plugin Developer | Freebies | Plugins
  02 February 2013
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
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
>>> 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]

Cinema 4D Plugin Developer | Freebies | Plugins
  02 February 2013
Here is a solution of my problem in a german forum!

Thank you Niklas!

Here is the Link:
  02 February 2013
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:19 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.