I want to execute an algorithm using SAGA GIS. I am using the following Python code.

outputwinddata_asc = "W:/04 Tools/07 MapMaker/workingfiles/Thailand_Rectangle2_DTU50m.asc"
outputwinddata_asc1 = "W:/04 Tools/07 MapMaker/workingfiles/Thailand_Rectangle2_DTU50m_SAGA.asc"

Its showing (as given below) that the output file is generated successfully.

{'RESULT': 'W:/04 Tools/07 MapMaker/workingfiles/SAGA.asc'}  

Unfortunately, I am not able to see any file with file name SAGA.asc in the folder W:/04 Tools/07 MapMaker/workingfiles.

Then, I tried by changing the folder of output file as given below.

outputwinddata_asc1 = "C:/Users/Sreeraj/Desktop/SAGA.asc"

Then the output file SAGA.asc is generated successfully in the folder C:/Users/Sreeraj/Desktop ; and I can see the output.

{'RESULT': 'W:/04 Tools/07 MapMaker/workingfiles/SAGA.asc'}

So, I found out that the difference is the spacing of folder names. C:/Users/Sreeraj/Desktop does not have any spaces in between folder names. But, for W:/04 Tools/07 MapMaker/workingfiles, there are spaces for 04 Tools and 07 MapMaker ( I mean 07 'space' MapMaker).

Unfortunately, I am not allowed to remove these spaces of folder names and I must keep the folder name W:/04 Tools/07 MapMaker/workingfiles as it is.

How can I solve this issue (without changing the name of output folder W:/04 Tools/07 MapMaker/workingfiles) ?

  • stackoverflow.com/questions/123198/…
    – fatih_dur
    Commented Feb 23, 2018 at 8:22
  • It's not always a problem with the spaces. See stackoverflow.com/a/14852407/930271. But try with '"W:/04 Tools/07 MapMaker/workingfiles/SAGA.asc"' Test in a console that the path really exists and you have permissions on it. Commented Feb 23, 2018 at 8:32
  • 1
    @FranciscoPuga That doesn't helped me. Only this algorithm is not giving output files to the folder W:/04 Tools/07 MapMaker/workingfiles/ . Maybe, SAGA GIS algorithms will not allow to use the folder names with spaces. The path really exists and the output is not generated only in the folders with spaces between characters. If the output folder name is in desktop, then output file is generated there (as mentioned in the question) without any issues because the full characters of the folder name of desktop used in question doesnot have any spaces.
    – Sreeraj
    Commented Feb 23, 2018 at 9:47
  • 1
    @fatih_dur This question is not regarding copying files. Please try to solve this issue after reading the entire question.
    – Sreeraj
    Commented Feb 23, 2018 at 9:48
  • 1
    You could try windows short file name, like here: code.activestate.com/recipes/286179-getshortpathname Commented Feb 23, 2018 at 10:04

1 Answer 1


I have solved this issue by using the Python recipe of win32api.GetShortPathName() as given below.

import win32api
outputwinddata_asc = win32api.GetShortPathName("W:/04 Tools/07 MapMaker/workingfiles/Thailand_Rectangle2_DTU50m.asc")
outputwinddata_asc1 = win32api.GetShortPathName("W:/04 Tools/07 MapMaker/workingfiles/Thailand_Rectangle2_DTU50m_SAGA.asc")

The above code solved the issue perfectly.

The only condition is that the win32api.GetShortPathName() will only works if the file already exists in the specified path.

If the output file doesnot exists in the output path, then it is possible to solve this issue prefectly as given below.

import win32api
outputwinddata_asc = win32api.GetShortPathName("W:/04 Tools/07 MapMaker/workingfiles/") + "Thailand_Rectangle2_DTU50m.asc"
outputwinddata_asc1 = win32api.GetShortPathName("W:/04 Tools/07 MapMaker/workingfiles/") + "Thailand_Rectangle2_DTU50m_SAGA.asc"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.