I want to change the data source of a layer (non geometric, just a table of fields) created from a .txt file. I know how to do it manually but I want to do it with the Python console. I have tried the setDataSource() command but I don't quite understand the arguments.
from qgis.core import QgsDataSourceUri
uri = QgsDataSourceUri()
uri.setDataSource("Path_to_new_source_txtfile","layer_name","memory")
This is the code I tried to use to change the source file, it didn't get me any error but it didn't change the source file either.