Counting the number of molecules over several SDF files


I want to read several SDF files, count the number of molecules in each file, and obtain the total number of molecules over all files.

I’ve set up a loop (as described here: that does read all the desired SDF files, but I am unclear how to extract the individual molecules counts (I guess counting the rows is an option – is there a counter node?) and total them (and possibly write them to a CSV file or similar, or just view the total)

thanks for the help!




Hi Scott!

If one molecule is one row then your guess is fine - count the number of rows will do it. There are multiple ways you can count the number of rows. One is using Extract Table Dimension node.

I have created an example how you can do it. Read files using loop, count number of rows per each file, calculate total number after loop is done and write it all in csv file. Input files are in workspace directory and output will be there as well :wink:

Take a look and if any questions feel free to ask.
2019_05_15_Reading_List_of_Files_and_Counting.knwf (38.2 KB)




Hi Ivan

it works great! thanks so much for your help.



1 Like