CatherineKan 3 Posted June 4, 2020 (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!! Edited June 5, 2020 by CatherineKan Share this post Link to post Share on other sites
anim 1,261 Posted June 5, 2020 Your main() call should not be indented Share this post Link to post Share on other sites
CatherineKan 3 Posted June 5, 2020 (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! Edited June 5, 2020 by CatherineKan figured out partial problem Share this post Link to post Share on other sites
konstantin magnus 1,162 Posted June 5, 2020 Unless you need something specific there is also node for importing csv-files: https://www.sidefx.com/docs/houdini/nodes/sop/tableimport.html Share this post Link to post Share on other sites
CatherineKan 3 Posted June 5, 2020 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
konstantin magnus 1,162 Posted June 5, 2020 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
CatherineKan 3 Posted June 5, 2020 (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 June 5, 2020 by CatherineKan Share this post Link to post Share on other sites
sant0s81 27 Posted June 6, 2020 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
CatherineKan 3 Posted June 6, 2020 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
sant0s81 27 Posted June 6, 2020 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
CatherineKan 3 Posted June 7, 2020 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~ Share this post Link to post Share on other sites
sant0s81 27 Posted June 8, 2020 Could you post a little scene or the code and part of the csv? Share this post Link to post Share on other sites
Librarian 840 Posted June 8, 2020 Here you have examples (if you already don't use this for you study ). https://dataarena.net/dive-in/tutorials/houdini/introduction https://www.youtube.com/watch?v=SwQ6gdNU7h4 vizi.rar 2 Share this post Link to post Share on other sites
CatherineKan 3 Posted June 9, 2020 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! 2 Share this post Link to post Share on other sites