Read CSV, output is columns the csv #35
Replies: 5 comments
-
As a start, you can convert Here's a format I suggested to a user on discord some months ago, and the one I recommend most for this case: ### third-party import
from pandas import read_csv
main_callable = read_csv
third_party_import_text = 'from pandas import read_csv'
def _read_csv(
filepath_or_buffer: 'filepath' = 'dummy_value',
**kwargs,
):
pass
signature_callable = _read_csv This way you can choose the .CSV files in your system by clicking the path preview widget in the Alternativelly, if you think it is more convenient for your use-case, you can expose specific parameters that you think you may want to use more often. Below, in addition to the ### third-party import
from pandas import read_csv
main_callable = read_csv
third_party_import_text = 'from pandas import read_csv'
def _read_csv(
filepath_or_buffer : 'filepath' = 'dummy_filepath',
*,
verbose : bool = False,
skip_blank_lines: bool =True,
**kwargs,
):
pass
signature_callable = _read_csv In the future, nodes in Nodezator will probably be able to hide unused sockets like can be done with Blender nodes:
Just for completeness, since ### third-party import
from pandas import read_csv
main_callable = read_csv
third_party_import_text = 'from pandas import read_csv' All of this is explained here, just in case you want to know more or understand how/why this works. |
Beta Was this translation helpful? Give feedback.
-
As for the second part of your question:
Every time your hit F12 your graph will execute, so your As for displaying the DataFrame resulting from your manipulation, there are number of options each with their own trade-offs, so it is up to you which one fits your needs best.
The usage of the browser suggested above can be further automated by creating a custom node that saves the DataFrame as html in a temporary file (for instance, using the Another alternative that will only be available in the future is another kind of viewer node called Approaching the second part of your question from a different perspective, maybe you want to know whether the graph can execute automatically every time you change a value in the graph (like viewer nodes in Blender for instance)? For now it is not possible, but it has already been suggested (#26) and listed among the requested features (#13). |
Beta Was this translation helpful? Give feedback.
-
Hi @KennedyRichard , thank you for your comprehensive replies. I think I may not have explained what I wanted in the 2nd part properly though. After having a dataframe, I want the node to have the columns exposed as sockets. However, these columns will not always have the same name. Imagine if this is my dataframe:
Then, I would want my node to have output sockets "calories" and "duration". But if my data was different, like
, then I would want to have "a" and "b" be the name of the output sockets. It seems to me like we have to define the output socket names in the function signature, which would be static and not dynamic, so I am wondering if there is a dynamic way to do this. Basically, once I load the csv into a dataframe and hit f12, there would be new socket names. |
Beta Was this translation helpful? Give feedback.
-
Another way of phrasing my question is like this: "Can I choose the names and quantity of output sockets inside the function itself, rather than in the signature?" |
Beta Was this translation helpful? Give feedback.
-
I regret to say as of now there's yet no way to define the outputs of nodes dynamically. Such idea sounds very useful and exciting, though. A similar idea, one of being able to edit the name of an output socket from a node instance in the app was also suggested by a user who also happened to be using If you think this is essential for your workflow or at least very desirable you can suggest this as a feature by creating a discussion in the Feature Request category or by commenting on the feature request list discussion #13. If you do this, of course I'll help you personally, though it will take some time though, since I have a lot on my plate. Let me know if you need anything else, and feel free to keep the questions coming. I intend to make the improvements you suggested to the manual (#36) this week. |
Beta Was this translation helpful? Give feedback.
-
Here is what I imagine for a node:
You double click it to choose a .CSV file
The outputs update dynamically to be Pandas columns named using the headers of the CSV file, so I could pipe those columns to new functions.
Does something like this seem possible?
Beta Was this translation helpful? Give feedback.
All reactions