Example #1
0
func NewGrossFilter(loadedfile table.LoadedFile) GrossFilter {
	colCount := loadedfile.ColumnCount
	rowCount := loadedfile.RowCount

	columnData := make([][]interface{}, colCount)
	start := 0
	if loadedfile.HasHeaders {
		start = 1
	}

	for i := 0; i < colCount; i++ {
		initialValues := make([]string, rowCount-start)
		for j := start; j < rowCount; j++ {
			initialValues[j-start] = loadedfile.GetData(j, i)
		}
		colData, err := types.ConvertValues(initialValues, loadedfile.ColumnInfo[i].TypeInfo)
		if err != nil {
			log.Printf("Converion of types failed - %s", err)
		}
		columnData[i] = colData
	}
	g := GrossFilter{columnData: columnData}
	g.LoadedFile = loadedfile
	return g
}
Example #2
0
func (file LoadedFile) LoadData() error {
	start := 0
	if file.HasHeaders {
		start = 1
	}
	file.convertedData = make([][]interface{}, file.RowCount)
	for i := 0; i < file.RowCount; i++ {
		file.convertedData[i] = make([]interface{}, file.ColumnCount)
	}
	for i := 0; i < file.ColumnCount; i++ {
		column := ColumnFrom2dArray(file.Data, i, start)
		convertedValues, err := types.ConvertValues(column, file.ColumnInfo[i].TypeInfo)
		if err != nil {
			return err
		}
		for j := start; j < file.RowCount; j++ {
			file.convertedData[j][i] = convertedValues[j-start]
		}
	}
	return nil
}