Thank you so much. This partly works. There is one problem though. We should have "list_of_all_electrodes" constant for all participants in the same order becuase in the "table_for_all_files", I need to have one specific electrode in one column for all people. For example, O1 in column 1. Some participants have an ERP value for it, while others have NaN.
This script putS the "nonexistent electrodes" at the end of each file.
I appreciate your time and help.