I have a database of molecules (500, lines SMILES) and I would like to bring out these molecules in file .sdf one by one? (1 molecule = 1 sdf file)
I try with the song Partitionning, but it proposes me percentages and it is not by group that I wish to leave the molecules.
I would say you need a loop where in each iteration you will take one row (1 molecule) and save it as a .sdf file. You can check Chunk Loop Start node and this example where you can see how to write multiple files using loop and flow variables
Why second topic with same question? Will close it if you don’t mind.
maybe you want to add more information. What is your input, what do you need to perform (some joining or converting) in KNIME workflow and what is your expected output… Adding examples help a lot.
I’m not so much into molecules so maybe someone will figure out what you need with information you presented.
Use the List Files node to list all the CSV files. Then the Table Row To Variable Loop Start node. After that you can use the nodes you already mentioned (use the “Location” variable for the File Reader node) and put the Variable Loop End node at the end.
My workflow looks like this: List of files (directory where are csv files) -> Table Row to Variable Loop Start -> File Reader -> Open Babel -> Colums Filter -> SDF Writer.
I do not see where to place Variable Loop End.
In File Reader “Use Variable: Location” does not make me walk this node.
I need to read 500 .csv files, pass them through the Openbabel node and then output 500 .sdf files
Sorry, use the “URL” Variable instead. I am confused now. I think I set the “Location” as the variable in my example before updating to KNIME 4.1 and now after updating it works with URL.
However, if you use the URL values, the File Reader will work fine.
Do you have 500 csv file? or 1 csv file with 500 lines?
If you have 500 csv files you have to follow my solution. If you have 1 csv file with 500 rows and want to write each line in a new file then follow the solution by @ipazin.
If you have several csv files and each of them has several rows and you want each line in each csv file to be written separately, then use the Chunk Loop inside the Table Row To Variable loop.
Pay attention to the file names created by flow variables.
You do not need to split the CSV file. Just follow the solution by @ipazin and use the Chunk Loop Start node after the File Reader node. At the end of your workflow, after the SDF Writer node, use the Variable Loop End node to close the loop (check my workflow example). And That’s it!