// fillCSVFieldDesc will set fieldDescMap[fieldName] = FieldDesc for parsing the CSV data
fillCSVFieldDesc will set fieldDescMap[fieldName] = FieldDesc for parsing the CSV data
// fillCSVFieldDesc will set fieldDescMap [ fieldName ] = FieldDesc for parsing the CSV data
func fillCSVFieldDesc(cellData string, fieldDescMap FieldDescMap, fieldName string) error {
	size := 1
	for s := range fieldDescMap[fieldName].Shape {
		size *= s
	}
	values := strings.Split(cellData, ",")
	if fieldDescMap[fieldName].IsSparse == false && fieldDescMap[fieldName].Shape == nil {
		fieldDescMap[fieldName].Shape = []int{len(values)}
	}
	if fieldDescMap[fieldName].IsSparse == false && size != len(values) {
		if size > 1 {
			return fmt.Errorf("column %s should be csv format dense tensor of %d element(s), but got %d element(s)", fieldName, size, len(values))
		}
		fieldDescMap[fieldName].Shape = []int{len(values)}
	}
	fieldDescMap[fieldName].Delimiter = ","
	for _, v := range values {
		intValue, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			_, err := strconv.ParseFloat(v, 32)
			if err == nil {
				fieldDescMap[fieldName].DType = Float
			}
		} else {
			if intValue > fieldDescMap[fieldName].MaxID {
				fieldDescMap[fieldName].MaxID = intValue
			}
		}
	}
	return nil
}
func fillCSVFieldDesc ( cellData string , fieldDescMap FieldDescMap , fieldName string ) error { size := 1 for s := range fieldDescMap [ fieldName ] . Shape { size *= s } values := strings . Split ( cellData , " " ) if fieldDescMap [ fieldName ] . IsSparse == false && fieldDescMap [ fieldName ] . Shape == nil { fieldDescMap [ fieldName ] . Shape = [ ] int { len ( values ) } } if fieldDescMap [ fieldName ] . IsSparse == false && size != len ( values ) { if size > 1 { return fmt . Errorf ( " " , fieldName , size , len ( values ) ) } fieldDescMap [ fieldName ] . Shape = [ ] int { len ( values ) } } fieldDescMap [ fieldName ] . Delimiter = " " for _ , v := range values { intValue , err := strconv . ParseInt ( v , 10 , 64 ) if err != nil { _ , err := strconv . ParseFloat ( v , 32 ) if err == nil { fieldDescMap [ fieldName ] . DType = Float } } else { if intValue > fieldDescMap [ fieldName ] . MaxID { fieldDescMap [ fieldName ] . MaxID = intValue } } } return nil }
fillCSVFieldDesc will set fieldDescMap[fieldName] = FieldDesc for parsing the CSV data
fillCSVFieldDesc will set fieldDescMap [ fieldName ] = FieldDesc for parsing the CSV data
// set shape only when the column is "DENSE" // implicit set shape if shape is not provided in SQL COLUMN clause // get dtype for csv values, use int64 and float32 only // set dtype to float32 once a float value come up // if the value is integer, record maxID