pbnjay / grate

A Go native tabular data extraction package. Currently supports .xls, .xlsx, .csv, .tsv formats.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xls reads "0" on rows with many integer values

zvandehy opened this issue · comments

commented
  • Attached is testing.xls test case
  • testing.tsv (filetype not supported by github) was created by copying testing.xls data into testing.tsv file
  • grate/xls/simple_test.go TestBasic was edited to use testing.xls and testing.tsv and to log all mismatches

func TestBasic(t *testing.T) {
	trueFile, err := os.ReadFile("../testdata/testing.tsv")
	if err != nil {
		t.Skip()
	}
	lines := strings.Split(string(trueFile), "\n")

	fn := "../testdata/testing.xls"
	wb, err := Open(fn)
	if err != nil {
		t.Fatal(err)
	}

	sheets, err := wb.List()
	if err != nil {
		t.Fatal(err)
	}
	for _, s := range sheets {
		sheet, err := wb.Get(s)
		if err != nil {
			t.Fatal(err)
		}


		i := 0
		for sheet.Next() {
			row := strings.Join(sheet.Strings(), "\t")
			if lines[i] != row {
				t.Logf("line %d mismatch: '%s' <> '%s'", i, row, lines[i])
			}
			i++
		}
	}

	err = wb.Close()
	if err != nil {
		t.Fatal(err)
	}
}

`
--- FAIL: TestBasic (0.00s)

/Users/zeke/Programming/grate/xls/simple_test.go:71: line 2 mismatch: 'b	0	0	0' <> 'b	2	3	4'

/Users/zeke/Programming/grate/xls/simple_test.go:71: line 4 mismatch: 'b	0	0	0' <> 'b	1	2	1'

/Users/zeke/Programming/grate/xls/simple_test.go:71: line 5 mismatch: 'b	0	0	0' <> 'b	4	3	2'

/Users/zeke/Programming/grate/xls/simple_test.go:71: line 6 mismatch: '0	0	0	0' <> '1	1	1   1'`

testing.xls

Hi,
Do you will fix it?

Thanks for the ping @nicola-spb - it was an easy fix once I had a chance to dig into the issue.
Cheers

Big Thanks and Respect!