It's kind of easy to do with a python script that you can run from the editor of the Qgis console.
First, you need to get your line layer and get the feature inside.
Then, you need to loop on your csvfile to get the distance and create the point with the interpolate
method of QgsGeometry.
Finally, add the created point to a new point layer.
The following do the trick, you just need to replace the values in the firsts lines (line_layer, csvfilepath, EPSG) to fit to your data:
import csv
from PyQt4.QtCore import QVariant
#Change as appropriate
layer_name = 'line_truck'
csvfile_path = 'C:/Users/ylecomte/Desktop/test.csv'
EPSG = '29902' # projected in meters units
#get layer and create csv iterator
layer = QgsMapLayerRegistry.instance().mapLayersByName(layer_name)[0]
csvfile = open(csvfile_path, 'rb')
reader = csv.reader(csvfile, delimiter=';')
header = reader.next()
#prepare output layer
mem_layer = QgsVectorLayer("Point?crs=epsg:"+EPSG, 'point', 'memory')
mem_layer.startEditing()
attr = [QgsField(header[0],QVariant.String),QgsField(header[1],QVariant.Double)]
prov =mem_layer.dataProvider()
prov.addAttributes(attr)
mem_layer.updateFields()
#preform the trick by looping on feature and csv
for feat in layer.getFeatures():
for row in reader:
new_feat = QgsFeature()
new_feat.setGeometry(feat.geometry().interpolate(float(row[0])))
new_feat.setAttributes(attr)
new_feat.setAttribute(0, float(row[0]))
new_feat.setAttribute(1,row[1])
mem_layer.addFeatures([new_feat])
#save results and add output to the canvas
mem_layer.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(mem_layer)
the new layer is added to your map canvas as a memory layer containing the needed points and the csv data in corresponding fields.