tombuildsstuff / trainline-stations-parser

Parses the Trainline.eu stations list into a Go object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trainline Stations Parser

This package allows you to parse the Trainline.eu Stations List into a Go object.

Example Usage

This assumes the file stations.csv (from the Trainline.eu repository) is present within the same folder.

package main

import (
    "log"
    "os"
    
    "github.com/tombuildsstuff/trainline-stations-parser/parser"
)

func main() {
    fileName := "stations.csv"
    stations, err := parser.Parse(fileName)
	if err != nil {
		log.Printf("Error parsing: %+v", err)
		os.Exit(1)
	}
	
    for _, station := range *stations {
        log.Printf("Station: %q in %q (%.6f, %.6f)", station.Name, station.Country, station.Latitude, station.Longitude)
    }
}

About

Parses the Trainline.eu stations list into a Go object

License:MIT License


Languages

Language:Go 100.0%