Jump to content

using python coding in houdini to import many columns data file


CatherineKan

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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!

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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.

 

Link to comment
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

Link to comment
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 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...