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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2013   #1
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

Result:


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

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


Thank You!
 
Old 02 February 2013   #2
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.

-N
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
Old 02 February 2013   #3
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
 
Old 02 February 2013   #4
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].
 
Old 02 February 2013   #5
>>> 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]


-Niklas
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
Old 02 February 2013   #6
Here is a solution of my problem in a german forum!

Thank you Niklas!

Here is the Link:

http://www.tutorials.de/cinema-4d/3...sv-fuellen.html
 
Old 02 February 2013   #7
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 01:44 AM.


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