This probably has an embarrassingly easy answer, but I’m not sure what it is.
In my python code, there is a part where I want to save an array (called “stokes_columns” which is just full of floats) into a text file.
I did this fine with the following:
np.savetxt('../all_pulsars_1400list/%s_1400list.txt' % pname,stokes_columns, delimiter='\t')
The error message I get says:
no such file or directory: ‘~/all_pulsars_1400list/J0543_1400list.txt’
Where J0543 is the first variable to be used for the ‘%s’
but – I don’t understand because of course there is no file called that – that is the file I am trying to create.
I’ve double checked the path and it exists.
Is there something obvious I’m doing wrong? Thank you.
You need to expand path to absolute path like this: