Skip to content

Commit

Permalink
Merge pull request #7 from prometheusresearch/validation_fixes
Browse files Browse the repository at this point in the history
remove LF requirement in validation
  • Loading branch information
ajinkyagadewar authored Feb 11, 2022
2 parents e9bac26 + e72e883 commit 0156ea3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 54 deletions.
4 changes: 0 additions & 4 deletions test_datasets/omop_52_csv_bad/care_site.csv

This file was deleted.

33 changes: 0 additions & 33 deletions validation/omop52csv/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package omop52csv

import (
"bufio"
"bytes"
"encoding/csv"
"fmt"
"io"
Expand Down Expand Up @@ -96,36 +94,6 @@ func makeRecordValidator(
return recValidator, errors
}

func checkCRLFLineEndings(
basePath string,
file string,
errors val.ErrorCollection,
) {
f, err := os.Open(filepath.Join(basePath, file))
if err != nil {
return
}
defer f.Close()

scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanBytes)

for scanner.Scan() {
b := scanner.Bytes()

if bytes.Equal(b, []byte{'\r'}) {
errors.FileError(file,
"Invalid CRLF line endings. LF line endings required")

break
}
//Break on the first line \n encountered
if bytes.Equal(b, []byte{'\n'}) {
break
}
}
}

func checkFileContents(
basePath string,
file string,
Expand Down Expand Up @@ -244,7 +212,6 @@ func ValidateOmop52(basePath string, files []string) val.ErrorCollection {
continue
}
checkFileContents(basePath, name, tableDefinition, errors)
checkCRLFLineEndings(basePath, name, errors)
}

return errors
Expand Down
17 changes: 0 additions & 17 deletions validation/omop52csv/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,6 @@ var _ = Describe("ValidateOmop52", func() {
},
))
})

It("Has wrong line endings", func() {
errors := omop.ValidateOmop52(
badDatasetPath,
[]string{
"care_site.csv",
},
)

Expect(errors.Errors["care_site.csv"]).To(ConsistOf(
val.Error{
Message: "Invalid CRLF line endings. LF line endings required",
Record: 0,
Column: "",
},
))
})
})

Describe("Record Issues", func() {
Expand Down

0 comments on commit 0156ea3

Please sign in to comment.