Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emilyselwood/gompcreader
Minor Planet Center reader writen in Go.
https://github.com/emilyselwood/gompcreader
Last synced: about 1 month ago
JSON representation
Minor Planet Center reader writen in Go.
- Host: GitHub
- URL: https://github.com/emilyselwood/gompcreader
- Owner: emilyselwood
- License: mit
- Created: 2014-10-04T21:01:07.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-16T10:23:18.000Z (over 5 years ago)
- Last Synced: 2024-04-17T03:58:15.280Z (9 months ago)
- Language: Go
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Minor Planet Center Reader #
[![Build Status](https://travis-ci.org/wselwood/gompcreader.svg?branch=master)](https://travis-ci.org/wselwood/gompcreader)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/emilyselwood/gompcreader/blob/master/LICENSE.md)
[![Docs](https://img.shields.io/badge/docs-godoc.org-blue.svg)](https://godoc.org/github.com/emilyselwood/gompcreader)## Overview ##
Simple Go library to read the minor planet center data files.
The go docs should be reasonable. If some thing doesn't seem to work please raise a bug.
The expected input files can be obtained here: http://www.minorplanetcenter.net/iau/MPCORB.html Either the gziped or unzipped files should work automatically, file type detection is done by simple file extension only.
## Example ##
```
package mainimport (
"flag"
"fmt"
"io"
"log""github.com/emilyselwood/gompcreader"
)var inputfile = flag.String("in", "", "the minor planet center file to read")
func main() {
flag.Parse()
if *inputfile == "" {
log.Fatal("No input file provided. Use the -in /path/to/file")
}mpcReader, err := gompcreader.NewMpcReader(*inputfile)
if err != nil {
log.Fatal("error creating mpcReader ", err)
}
defer mpcReader.Close()var count int64
result, err := mpcReader.ReadEntry()
for err == nil {
fmt.Printf("%s:%s\n", result.ID, result.ReadableDesignation)
result, err = mpcReader.ReadEntry()
count = count + 1
}if err != nil && err != io.EOF {
log.Fatal(fmt.Sprintf("error reading line %d\n", count), err)
}fmt.Printf("read %d records\n", count)
}```