func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) RecordUnmarshaller {
	return func(text string) (pilosa.Record, error) {
		var err error
		column := pilosa.Column{}
		parts := strings.Split(text, ",")
		if len(parts) < 2 {
			return nil, errors.New("Invalid CSV line")
		}

		hasRowKey := format == RowKeyColumnID || format == RowKeyColumnKey
		hasColumnKey := format == RowIDColumnKey || format == RowKeyColumnKey

		if hasRowKey {
			column.RowKey = parts[0]
		} else {
			column.RowID, err = strconv.ParseUint(parts[0], 10, 64)
			if err != nil {
				return nil, errors.New("Invalid row ID")
			}
		}

		if hasColumnKey {
			column.ColumnKey = parts[1]
		} else {
			column.ColumnID, err = strconv.ParseUint(parts[1], 10, 64)
			if err != nil {
				return nil, errors.New("Invalid column ID")
			}
		}

		timestamp := 0
		if len(parts) == 3 {
			if timestampFormat == "" {
				timestamp, err = strconv.Atoi(parts[2])
				if err != nil {
					return nil, err
				}
			} else {
				t, err := time.Parse(timestampFormat, parts[2])
				if err != nil {
					return nil, err
				}
				timestamp = int(t.Unix())
			}
		}
		column.Timestamp = int64(timestamp)

		return column, nil
	}
}
func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) RecordUnmarshaller {
	return func(text string) (pilosa.Record, error) {
		var err error
		column := pilosa.Column{}
		parts := strings.Split(text, ",")
		if len(parts) < 2 {
			return nil, errors.New("Invalid CSV line")
		}

		hasRowKey := format == RowKeyColumnID || format == RowKeyColumnKey
		hasColumnKey := format == RowIDColumnKey || format == RowKeyColumnKey

		if hasRowKey {
			column.RowKey = parts[0]
		} else {
			column.RowID, err = strconv.ParseUint(parts[0], 10, 64)
			if err != nil {
				return nil, errors.New("Invalid row ID")
			}
		}

		if hasColumnKey {
			column.ColumnKey = parts[1]
		} else {
			column.ColumnID, err = strconv.ParseUint(parts[1], 10, 64)
			if err != nil {
				return nil, errors.New("Invalid column ID")
			}
		}

		timestamp := 0
		if len(parts) == 3 {
			if timestampFormat == "" {
				timestamp, err = strconv.Atoi(parts[2])
				if err != nil {
					return nil, err
				}
			} else {
				t, err := time.Parse(timestampFormat, parts[2])
				if err != nil {
					return nil, err
				}
				timestamp = int(t.Unix())
			}
		}
		column.Timestamp = int64(timestamp)

		return column, nil
	}
}
func ColumnUnmarshallerWithTimestamp ( format Format , timestampFormat string ) RecordUnmarshaller { return func ( text string ) ( pilosa . Record , error ) { var err error column := pilosa . Column { } parts := strings . Split ( text , " " ) if len ( parts ) < 2 { return nil , errors . New ( " " ) } hasRowKey := format == RowKeyColumnID || format == RowKeyColumnKey hasColumnKey := format == RowIDColumnKey || format == RowKeyColumnKey if hasRowKey { column . RowKey = parts [ 0 ] } else { column . RowID , err = strconv . ParseUint ( parts [ 0 ] , 10 , 64 ) if err != nil { return nil , errors . New ( " " ) } } if hasColumnKey { column . ColumnKey = parts [ 1 ] } else { column . ColumnID , err = strconv . ParseUint ( parts [ 1 ] , 10 , 64 ) if err != nil { return nil , errors . New ( " " ) } } timestamp := 0 if len ( parts ) == 3 { if timestampFormat == " " { timestamp , err = strconv . Atoi ( parts [ 2 ] ) if err != nil { return nil , err } } else { t , err := time . Parse ( timestampFormat , parts [ 2 ] ) if err != nil { return nil , err } timestamp = int ( t . Unix ( ) ) } } column . Timestamp = int64 ( timestamp ) return column , nil } }
// ColumnUnmarshallerWithTimestamp creates a RecordUnmarshaller for importing columns with the given format and timestamp format.
ColumnUnmarshallerWithTimestamp creates a RecordUnmarshaller for importing columns with the given format and timestamp format .