Jump to content

[Solved] Opdef not working with .csv files?


sant0s81

Recommended Posts

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

@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...

 

csv_ef.jpg

Edited by sant0s81
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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...

 

  • 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...