I am able to attach a raster by using python console using the command shown below.
qgis.utils.iface.addRasterLayer('D:/Work/dt0017810q.tif')
But, when the same image/raster path is read from a text file using a customized plugin (which I developed), the addRasterLayer method/function throws an error message
Invalid Layer: GDAL provider Cannot open GDAL dataset D:/Work/dt0017810q.tif : `D:/Work/dt0017810q.tif ' does not exist in the file system, and is not recognized as a supported dataset name. Raster layer Provider is not valid (provider: gdal, URI: D:/Work/dt0017810q.tif
How to fix this?