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" />
  • 4
    It may be easier to merge the CSVs outside of QGIS first (using CMD Prompt if on Windows) then just import a single file. This will also allow you to put in a header line to the single CSV file first.
    – JClarkson
    Dec 8, 2020 at 16:07
  • 2
    The driver will also accept a semicolon, a tabulation or a space character as field separator from gdal.org/drivers/vector/csv.html
    – Ian Turton
    Dec 8, 2020 at 17:07
  • 2
    non-GIS tools will likely help you here: stackoverflow.com/questions/25596171/… Dec 8, 2020 at 21:42
  • Anyway after merging and getting ogrinfo fro VRT I get Warning 1: Value '→' of field merged.x parsed incompletely to integer 0. Extent: (-877500.000000, -1020000.000000) - (0.000000, 0.000000) with wrong extent. I don't know where the arrow character comes from.
    – Albine Pro
    Dec 9, 2020 at 8:53

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.

  • After the merge I have 11 millions of rows. Any idea how to delete the sign at the bottom? I was trying to convert XYZ into raster - finally did by merging in CMD, loading to QGIS as layer, saving to GeoPackage and rasterize. I have tried with gdal_grid from VRT, but it was too slow (maybe because of the wrong extent).
    – Albine Pro
    Dec 9, 2020 at 11:18
  • Honestly, I never figured out the carriage return thing outside of excel. My only advice is to make 11 or 12 different files (so they're small enough to open) and just work with them like that. Sorry.
    – JClarkson
    Dec 9, 2020 at 11:23
  • 1
    This answer brings solution how to avoid appending final hex 1A character.
    – Albine Pro
    Dec 11, 2020 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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