func ParseTabFile(tabPath string) (*TabFile, error) {
	f, err := os.Open(tabPath)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	fileCSV := csv.NewReader(f)
	fileCSV.Comma = '\t'

	recs, err := fileCSV.ReadAll()
	if err != nil {
		log.Fatalln(err)
	}

	output := NewTabFile()

	for i, row := range recs {
		if l := len(row); l != 3 {
			return nil, fmt.Errorf("Tabfile %s row %d had %d columns, expected 3", tabPath, i, l)
		}

		if i == 0 {
			// header
			continue
		}
		entry := TabEntry{
			Values:  strings.Split(row[1], ","),
			Exclude: row[2] == "1",
		}
		entry.FieldID, err = strconv.Atoi(row[0])
		if err != nil {
			return nil, err
		}

		// Assign to the right field type
		switch entry.Exclude {
		case true:
			if IsHesin(entry.FieldID) {
				output.Exclude.Hesin = append(output.Exclude.Hesin, entry)
			} else if IsSpecial(entry.FieldID) {
				output.Exclude.Special = append(output.Exclude.Special, entry)
			} else {
				output.Exclude.Standard = append(output.Exclude.Standard, entry)
			}
		default:
			if IsHesin(entry.FieldID) {
				output.Include.Hesin = append(output.Include.Hesin, entry)
			} else if IsSpecial(entry.FieldID) {
				output.Include.Special = append(output.Include.Special, entry)
			} else {
				output.Include.Standard = append(output.Include.Standard, entry)
			}
		}
	}

	return output, nil
}
// ParseTabFile consumes a tabfile and returns our machine representation of
// that file
ParseTabFile consumes a tabfile and returns our machine representation of
that file
// ParseTabFile consumes a tabfile and returns our machine representation of // that file
func ParseTabFile(tabPath string) (*TabFile, error) {
	f, err := os.Open(tabPath)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	fileCSV := csv.NewReader(f)
	fileCSV.Comma = '\t'
	recs, err := fileCSV.ReadAll()
	if err != nil {
		log.Fatalln(err)
	}
	output := NewTabFile()
	for i, row := range recs {
		if l := len(row); l != 3 {
			return nil, fmt.Errorf("Tabfile %s row %d had %d columns, expected 3", tabPath, i, l)
		}
		if i == 0 {
			continue
		}
		entry := TabEntry{
			Values:  strings.Split(row[1], ","),
			Exclude: row[2] == "1",
		}
		entry.FieldID, err = strconv.Atoi(row[0])
		if err != nil {
			return nil, err
		}
		switch entry.Exclude {
		case true:
			if IsHesin(entry.FieldID) {
				output.Exclude.Hesin = append(output.Exclude.Hesin, entry)
			} else if IsSpecial(entry.FieldID) {
				output.Exclude.Special = append(output.Exclude.Special, entry)
			} else {
				output.Exclude.Standard = append(output.Exclude.Standard, entry)
			}
		default:
			if IsHesin(entry.FieldID) {
				output.Include.Hesin = append(output.Include.Hesin, entry)
			} else if IsSpecial(entry.FieldID) {
				output.Include.Special = append(output.Include.Special, entry)
			} else {
				output.Include.Standard = append(output.Include.Standard, entry)
			}
		}
	}
	return output, nil
}
func ParseTabFile ( tabPath string ) ( * TabFile , error ) { f , err := os . Open ( tabPath ) if err != nil { return nil , err } defer f . Close ( ) fileCSV := csv . NewReader ( f ) fileCSV . Comma = '\t' recs , err := fileCSV . ReadAll ( ) if err != nil { log . Fatalln ( err ) } output := NewTabFile ( ) for i , row := range recs { if l := len ( row ) ; l != 3 { return nil , fmt . Errorf ( " " , tabPath , i , l ) } if i == 0 { continue } entry := TabEntry { Values : strings . Split ( row [ 1 ] , " " ) , Exclude : row [ 2 ] == " " , } entry . FieldID , err = strconv . Atoi ( row [ 0 ] ) if err != nil { return nil , err } switch entry . Exclude { case true : if IsHesin ( entry . FieldID ) { output . Exclude . Hesin = append ( output . Exclude . Hesin , entry ) } else if IsSpecial ( entry . FieldID ) { output . Exclude . Special = append ( output . Exclude . Special , entry ) } else { output . Exclude . Standard = append ( output . Exclude . Standard , entry ) } default : if IsHesin ( entry . FieldID ) { output . Include . Hesin = append ( output . Include . Hesin , entry ) } else if IsSpecial ( entry . FieldID ) { output . Include . Special = append ( output . Include . Special , entry ) } else { output . Include . Standard = append ( output . Include . Standard , entry ) } } } return output , nil }
ParseTabFile consumes a tabfile and returns our machine representation of
that file
ParseTabFile consumes a tabfile and returns our machine representation of that file
// header // Assign to the right field type