sant0s81 Posted June 17, 2020 Share Posted June 17, 2020 (edited) Hey, I am trying to add a .csv file to "Extra Files". With pictures it works perfect when using "opdef:/Object/X_Pounder_Gun?Cannon_Barrel_COLOR.tif" But with .csv files it doesnt work. Doesnt it work in gerneral? Thx alot, sant0s Edited June 18, 2020 by sant0s81 Quote Link to comment Share on other sites More sharing options...
Librarian Posted June 17, 2020 Share Posted June 17, 2020 Don't think you can do CSV import with opdef ...You have table import https://www.niklasrosenstein.com/post/2017-07-26-houdini-import-csv-node/ 1 Quote Link to comment Share on other sites More sharing options...
sant0s81 Posted June 17, 2020 Author Share Posted June 17, 2020 (edited) @Librarian thx. The import I do with python, since the .csv's I have are quite a mess and to extract some values, it was more easy with python. And the "Extra files" option would make it a bit more organized. I have the .csv file loaded and it also shows the text inside. But than probably opdef doesnt like .csv... Edited June 17, 2020 by sant0s81 Quote Link to comment Share on other sites More sharing options...
anim Posted June 17, 2020 Share Posted June 17, 2020 opdef: doesn't care what file you are referencing from the extra files section, operators that support is would be able to access the file through opdef:file handler but since it's not a direct file, python os module will probably not be able to find it on its own, (Table Import is also python based so will probably not work either) I'm not sure if there is a way to use opdef: file handler with python to resolve as file object or something 1 Quote Link to comment Share on other sites More sharing options...
sant0s81 Posted June 17, 2020 Author Share Posted June 17, 2020 @anim and @Librarian I send my question and the files to the support. Its now marked as a bug and they will let me know. I let you know when I get an answer. Thx again sant0s Quote Link to comment Share on other sites More sharing options...
sant0s81 Posted June 18, 2020 Author Share Posted June 18, 2020 Hey guys, here is what I got from the support: Quote Our developers comment: First, the node type in the attached HDA file is "sant0s_import_csv_as_points", not "Import_CSV" as implied by the "opdef:" path given in the File parameter value. Second, native python file IO methods (such as the "with open(path) as f:") has no idea what to do with an "opdef:" path. Only HOM methods will know how to read files with paths of that format. This is precisely what the hou.readFile() method is for. It reads a file using any path that Houdini can understand (such as these opdef: paths) and returns the file contents as a string. The python StringIO library can be used to read from a string as if it were a file. So replace the "with open..." line with this code, and it works fine: import StringIO csvio = StringIO.StringIO(hou.readFile(path)) reader = csv.reader(csvio) etc... 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.