Jump to content
CatherineKan

using python coding in houdini to import many columns data file

Recommended Posts

Posted (edited)

In order to write code in SOP python node, do I need to have a python software in my local computer?

Because I tried to write some code in python node to import my data files, it seemed not working.

What I have coded is attached.

Thanks!!

Screenshot (53).png

Edited by CatherineKan

Share this post


Link to post
Share on other sites

Your main() call should not be indented

Share this post


Link to post
Share on other sites
Posted (edited)
14 hours ago, anim said:

Your main() call should not be indented

Thanks so much! I am not familiar with python, just watched video and coded this.

 

Continue with my problem, if I would like to import csv files, for the final reading of all data, I think it needs a for loop?

What I have tried to do is to extract each column (200 columns in total) to each attribute with name "conc%d"%(j). But it seemed not working properly, only one column is imported.

The 200 empty attributes were successfully imported, though.

 

Many thanks in advance!

 

 

 

Screenshot (60).png

Edited by CatherineKan
figured out partial problem

Share this post


Link to post
Share on other sites
3 hours ago, konstantin magnus said:

Unless you need something specific there is also node for importing csv-files:
https://www.sidefx.com/docs/houdini/nodes/sop/tableimport.html

Yah, I tried this node before, but I have 200 columns of data in my file, so I think I could only code for importing?

What I found is that the tableimport node only could manually import each column into the Houdini spreadsheet?

Please correct me if I am wrong~ Thanks!

Share this post


Link to post
Share on other sites

Well, you could click on that little plus before 'column number' to set up numerous attributes. But once you have a working script I guess that's more convenient.

Share this post


Link to post
Share on other sites
Posted (edited)
3 hours ago, konstantin magnus said:

Well, you could click on that little plus before 'column number' to set up numerous attributes. But once you have a working script I guess that's more convenient.

Yah, since I have 200 columns, I guess I still need codes.

Because although I can change "column number", but for each column, I need to manually change 200 of them and naming each one? There should be an easier way?

Thanks anyway, I can search more and wait for further help~

Edited by CatherineKan

Share this post


Link to post
Share on other sites

I actually dont got, what you wanna do.

Just did some .csv reading, parsing and writing stuff.
So if you could be a bit more specific it would help to help. :)

 

Share this post


Link to post
Share on other sites
7 hours ago, sant0s81 said:

I actually dont got, what you wanna do.

Just did some .csv reading, parsing and writing stuff.
So if you could be a bit more specific it would help to help. :)

 

Yeah, I just want to read in my csv files, I think reading part works well. But I also would like to extract each column and then assign each column to a attribute created in Houdini. I have already created my empty attributes, but only one column was successfully assigned to created attribute, I do not know why the other columns were not assigned to attributes. I think there might be some problems with my for loops code at the end of the script.

Share this post


Link to post
Share on other sites
2 hours ago, CatherineKan said:

Yeah, I just want to read in my csv files, I think reading part works well. But I also would like to extract each column and then assign each column to a attribute created in Houdini. I have already created my empty attributes, but only one column was successfully assigned to created attribute, I do not know why the other columns were not assigned to attributes. I think there might be some problems with my for loops code at the end of the script.

Did you check the tutorial I added below?

I folowed that and can read my csv in a similar way.

I just dont know, how to read the csv vertical instead of horizontal.
At least I understand, that you read in the "lines" vertical, right?

But check that tutorial, after that it should be more clear.

 

Share this post


Link to post
Share on other sites
23 hours ago, sant0s81 said:

Did you check the tutorial I added below?

I folowed that and can read my csv in a similar way.

I just dont know, how to read the csv vertical instead of horizontal.
At least I understand, that you read in the "lines" vertical, right?

But check that tutorial, after that it should be more clear.

 

Thanks, but I think I got the reader part good. 

My problem is that I cannot assign each column read in to the attribute in Houdini, as you can see there is only the first column assigned to my first created attribute, it seems like my outer for loop "for int j in range (200)" did not work, I do not know what is the right way to assign all my columns to attributes correspondingly~

Screenshot (64).png

Share this post


Link to post
Share on other sites

Could you post a little scene or the code and part of the csv?

 

Share this post


Link to post
Share on other sites

I found the fastest way to use python code to control tableimport node, so that importing columns of data could be achieved but not manually add them.

We can use a python node, with coding a few lines and a for loop in the script window, it controls all parameters you want to edit in tableimport node! Yeah!

Screenshot (70).png

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×