'unexpected '\r' carriage return from np.loadtxt

I am reading a .dat file using the following command

accel_x = np.loadtxt('./GroundMotions/GM/%s_%s_%s_%s_x.dat' % (station, realization, soilpro, profile))

where station, realization, soilpro, and profile are all Strings.

Then python throws me an error:

FileNotFoundError: [Errno 2] No such file or directory: './GroundMotions/GM/Z0XOCS_csz002_C4_WA-DNR-08_14\r_x.dat'

There is an unexpected \r in the error message. How can I avoid this unexpected carriage return?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source