I have list of many XYZ files with points without header an space delimited.


-877500 -1014000 471.95
-877500 -1013995 472.28
-877500 -1013990 472.61
-877500 -1013985 473.04
-877500 -1013980 473.39

I would like to merge all files into one QGIS point layer. I was trying this tutorial and no luck with Python. Anyway it doesn't describe working with CSV files as I have trouble defining sole VRT with custom delimiter. I couldn't find definitions for them in VRT driver neither CSV driver.

When trying ogrinfo with .xyz file couldn't read the file. If I change the extension to .csv it reads without trouble. I was not aware that <OGRVRTLayer name=" "> has to be the same as CSV file without extension. Finally I managed to combine files with suggestions from comments and using this code:

    <OGRVRTLayer name="merged">
        <SrcDataSource relativeToVRT=1>merged.csv</SrcDataSource>
        <GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
        <Field name="x" type="Integer" src="field_1" />
        <Field name="y" type="Integer" src="field_2" />
        <Field name="z" type="Real" src="field_3" />

1 Answer 1


A little confused about your file extensions, but assuming they are CSV...

If you have a folder containing your multiple files e.g.

enter image description here

You can run a command in Windows CMD Prompt to merge these with ease (Run the command window from that folder - either open it through Windows Explorer or cd to it):

copy *.csv merged.csv

This will create a new file called merged.csv which contains all records from other CSVs it found (watch out here as over 1 million rows and you will not be able to open it in Excel).

Looking in my new merged file I can do the following:

  1. Remove the carriage return at the bottom

enter image description here

  1. Add a header row (If you have a header file you can do this in a second merge process by using copy header.csv + merged.csv finished.csv)

Providing this is all well and dandy, you can then import this into QGIS using Add Delimited Text Layer and define a custom delimiter if you need it. Point QGIS to the X and Y field (if it hasn't grabbed them automatically), define your projection and import it.


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.