// ParseOmimCsv parse Omim_onto.csv
// @return a map with the FieldNumber in key
ParseOmimCsv parse Omim_onto.csv
@return a map with the FieldNumber in key
// ParseOmimCsv parse Omim_onto . csv // @return a map with the FieldNumber in key
func parseOmimCsv() (map[string]omimStruct, error) {
	omimCsvFile, err := os.Open("datas/omim/omim_onto.csv")
	if err != nil {
		return nil, err
	}
	dicCsv := make(map[string]omimStruct)
	reader := bufio.NewReader(omimCsvFile)
	headLine, err := reader.ReadString('\n') 
	if err != nil {
		return nil, err
	}
	header := strings.Split(headLine, ",") 
	for {
		line, err := reader.ReadString('\n') 
		if err != nil {
			if err == io.EOF {
				break
			}
			return nil, err
		}
		finalValues := make([]string, len(header)) 
		fields := strings.Split(line[:len(line)-1], ",")
		if len(fields) > len(header) {
			var fieldVal string
			var isQuote bool
			i := 0
			for _, value := range fields {
				if len(value) <= 0 {
					if !isQuote {
						i++
					}
				} else if value[0] == '"' {
					isQuote = true
					fieldVal = value
				} else if isQuote {
					fieldVal += "," + value
					if value[len(value)-1] == '"' {
						isQuote = false
						finalValues[i] = fieldVal
						i++
					}
				} else {
					finalValues[i] = value
					i++
				}
			}
		} else if len(fields) == len(header) {
			finalValues = fields
		} else {
			err = errors.New("Incorrect Document")
			return nil, err
		}
		id := finalValues[0][len(fields[0])-6:]
		doc := omimStruct{
			FieldNumber:          id,
			FieldDeseaseName:     finalValues[1],
			FieldObsolete:        finalValues[4] == "true",
			FieldCUI:             finalValues[5],
			FieldSemanticTypes:   finalValues[6],
			FieldDiseaseSynonyms: finalValues[2],
		}
		dicCsv[id] = doc
	}
	return dicCsv, nil
}
func parseOmimCsv ( ) ( map [ string ] omimStruct , error ) { omimCsvFile , err := os . Open ( " " ) if err != nil { return nil , err } dicCsv := make ( map [ string ] omimStruct ) reader := bufio . NewReader ( omimCsvFile ) headLine , err := reader . ReadString ( '\n' ) if err != nil { return nil , err } header := strings . Split ( headLine , " " ) for { line , err := reader . ReadString ( '\n' ) if err != nil { if err == io . EOF { break } return nil , err } finalValues := make ( [ ] string , len ( header ) ) fields := strings . Split ( line [ : len ( line ) - 1 ] , " " ) if len ( fields ) > len ( header ) { var fieldVal string var isQuote bool i := 0 for _ , value := range fields { if len ( value ) <= 0 { if ! isQuote { i ++ } } else if value [ 0 ] == '"' { isQuote = true fieldVal = value } else if isQuote { fieldVal += " " + value if value [ len ( value ) - 1 ] == '"' { isQuote = false finalValues [ i ] = fieldVal i ++ } } else { finalValues [ i ] = value i ++ } } } else if len ( fields ) == len ( header ) { finalValues = fields } else { err = errors . New ( " " ) return nil , err } id := finalValues [ 0 ] [ len ( fields [ 0 ] ) - 6 : ] doc := omimStruct { FieldNumber : id , FieldDeseaseName : finalValues [ 1 ] , FieldObsolete : finalValues [ 4 ] == " " , FieldCUI : finalValues [ 5 ] , FieldSemanticTypes : finalValues [ 6 ] , FieldDiseaseSynonyms : finalValues [ 2 ] , } dicCsv [ id ] = doc } return dicCsv , nil }
ParseOmimCsv parse Omim_onto.csv
@return a map with the FieldNumber in key
ParseOmimCsv parse Omim_onto . csv @return a map with the FieldNumber in key
// first line // array with the fields names // current line // array with the final field's values