Aug-30-2018, 09:59 AM
(This post was last modified: Aug-30-2018, 10:12 AM by clarablanes.)
I did the change but it says the same.
File 'CONFIG_iterator.py", line 3
with open('CONFIG.inp') as cf, open('CONFIG{}inp'.format(i), 'w') as f:
^
SyntaxError: invalid syntax
Regarding to the version, I have to work in the university server because the programs I use are installed there
Thank you for your code but I think that the problem is that I have to work in the university server and the installed version is 2.6.6.
Dear buran and Gribouillis,
I have tested your codes in my machine with python 3 and they work perfectly!. So,I will do this iteration in my machine and then continue with the university server. Thank you very much you both for your fantastic work.
clara
File 'CONFIG_iterator.py", line 3
with open('CONFIG.inp') as cf, open('CONFIG{}inp'.format(i), 'w') as f:
^
SyntaxError: invalid syntax
Regarding to the version, I have to work in the university server because the programs I use are installed there
(Aug-30-2018, 09:51 AM)Gribouillis Wrote: Yes, upgrade to python 3 before you do anything. Here is a complete code for python 3. You only need to save it in the same directory as CONFIG.inp and run it (you can replace the 'names' list by your own names list)
import io with open('CONFIG.inp') as infile: lines = infile.readlines() lines[2] = lines[2].replace('ligand.inp', '{ligand}.inp') with io.StringIO() as f: f.writelines(lines) template = f.getvalue() names = ['foo', 'bar', 'baz'] for idx, name in enumerate(names, 1): with open('CONFIG{}.inp'.format(idx), 'w') as outfile: outfile.write(template.format(ligand=name))
Thank you for your code but I think that the problem is that I have to work in the university server and the installed version is 2.6.6.
Dear buran and Gribouillis,
I have tested your codes in my machine with python 3 and they work perfectly!. So,I will do this iteration in my machine and then continue with the university server. Thank you very much you both for your fantastic work.
clara