# Problem with writing a batch of routes to a GeoJSON file

**URL:** <https://ask.openrouteservice.org/t/problem-with-writing-a-batch-of-routes-to-a-geojson-file/1122>\
**Category:** openrouteservice\
**Created:** [November 26, 2019, 1:15pm UTC](https://ask.openrouteservice.org/t/problem-with-writing-a-batch-of-routes-to-a-geojson-file/1122 "2019-11-26T13:15:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stustokeld](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/stustokeld/32/255_2.png) [@stustokeld](https://ask.openrouteservice.org/u/stustokeld)\
**Post date:** [November 26, 2019, 1:15pm UTC](https://ask.openrouteservice.org/t/problem-with-writing-a-batch-of-routes-to-a-geojson-file/1122/1 "2019-11-26T13:15:51Z")

</div>

I am trying to return routes from a batch of coordinates to a single location. This is a volunteer project for a local foodbank and I am quite inexperienced in writing code.

Here is what I wrote in Python:

```
    import csv
import openrouteservice
from openrouteservice import convert

client = openrouteservice.Client(key='5b3ce3597851110001cf624863085b996464465cbf0974fe690fc4ef')
with open ('ClientCoordinates10test.csv' , 'r') as csv_coords:
    csv_reader = csv.reader(csv_coords) 
    EXTRA_COORD = (2.23179, 53.464774)
    new_csv_coords = []
    routelist = []
    for line in csv_reader:
        new_csv_coords.append(((float(line[0]), float(line[1])), EXTRA_COORD))
            
        coords = (new_csv_coords)
        print(coords[0]) 
        routes = client.directions(coords[0])
        
        decoded = convert.decode_polyline(routes['routes'][0]['geometry'])
        
        print(decoded) 
        
        routelist.append(decoded)

# create a file to write to
f = open('route.geojson', 'w+')

# write our path to the file
f.write(str(routelist))

```

However when I try to load the GeoJSON into QGIS I get an “invalid GeoJSON” error. I’m wondering whether I need to write more properties to the GeoJSON? and if so how do I do this?

Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)\
**Post date:** [November 27, 2019, 6:08am UTC](https://ask.openrouteservice.org/t/problem-with-writing-a-batch-of-routes-to-a-geojson-file/1122/2 "2019-11-27T06:08:00Z")

</div>

Well, as far as I can see, you’re not generating a GeoJSON, just a list of coordinates. As there’s multiple things “wrong” here, it’ll be a whole lot easier for you to install [ORS Tools](https://plugins.qgis.org/plugins/ORStools/) for QGIS, which makes the above code redundant.
