grate
A Go native tabular data extraction package. Currently supports .xls
, .xlsx
, .csv
, .tsv
formats.
Why?
Grate focuses on speed and stability first, and makes no attempt to parse charts, figures, or other content types that may be present embedded within the input files. It tries to perform as few allocations as possible and errs on the side of caution.
There are certainly still some bugs and edge cases, but we have run it successfully on a set of 400k .xls
and .xlsx
files to catch many bugs and error conditions. Please file an issue with any feedback and additional problem files.
Usage
Grate provides a simple standard interface for all supported filetypes, allowing access to both named worksheets in spreadsheets and single tables in plaintext formats.
package main
import (
"fmt"
"os"
"strings"
"github.com/jackhopner/grate"
_ "github.com/jackhopner/grate/simple"
_ "github.com/jackhopner/grate/xls"
_ "github.com/jackhopner/grate/xlsx"
)
func main() {
wb, _ := grate.Open(os.Args[1])
sheets, _ := wb.List()
for _, s := range sheets {
sheet, _ := wb.Get(s)
for sheet.Next() {
row := sheet.Strings()
fmt.Println(strings.Join(row, "\t"))
}
}
wb.Close()
}
License
All source code is licensed under the MIT License.