@@ -77,66 +77,6 @@ trait MetaDataValidator {
7777 validateKnownRows(csv, schema, pf)
7878 }
7979
80- /**
81- * Browse csv File and return all the titleIndex as a list
82- * @param csv the CSV reader
83- * @param schema the Schema
84- * @param columnIndex the index of the column to be return
85- * @return all the element of the column columnIndex
86- */
87- def getColumn (csv : JReader , schema : Schema , columnIndex : Int ): List [String ] = {
88-
89- val separator = schema.globalDirectives.collectFirst {
90- case Separator (sep) =>
91- sep
92- }.getOrElse(CSVParser .DEFAULT_SEPARATOR )
93-
94- val quote = schema.globalDirectives.collectFirst {
95- case q : Quoted =>
96- CSVParser .DEFAULT_QUOTE_CHARACTER
97- }
98-
99- // TODO CSVReader does not appear to be RFC 4180 compliant as it does not support escaping a double-quote with a double-quote between double-quotes
100- // TODO CSVReader does not seem to allow you to enable/disable quoted columns
101- // we need a better CSV Reader!
102- (managed(new CSVReader (csv, separator, CSVParser .DEFAULT_QUOTE_CHARACTER , CSVParser .NULL_CHARACTER )) map {
103- reader =>
104- // if 'no header' is set but the file is empty and 'permit empty' has not been set - this is an error
105- // if 'no header' is not set and the file is empty - this is an error
106- // if 'no header' is not set and 'permit empty' is not set but the file contains only one line - this is an error
107-
108- val rowIt = new RowIterator (reader, None )
109-
110- val maybeNoData =
111- if (schema.globalDirectives.contains(NoHeader ())) {
112- if (! rowIt.hasNext && ! schema.globalDirectives.contains(PermitEmpty ())) {
113- Some (FailMessage (ValidationError , " metadata file is empty but this has not been permitted" ).failureNel[Any ])
114- } else {
115- None
116- }
117- } else {
118- if (! rowIt.hasNext) {
119- Some (FailMessage (ValidationError , " metadata file is empty but should contain at least a header" ).failureNel[Any ])
120- } else {
121- if (! rowIt.hasNext && ! schema.globalDirectives.contains(PermitEmpty ())) {
122- Some (FailMessage (ValidationError , " metadata file has a header but no data and this has not been permitted" ).failureNel[Any ])
123- } else {
124- None
125- }
126- }
127- }
128-
129- maybeNoData match {
130- case Some (noData) =>
131- Nil
132- case None =>
133- getColumn(rowIt, columnIndex)
134-
135- }
136- } opt).getOrElse(Nil )
137- }
138-
139-
14080 def validateKnownRows (csv : JReader , schema : Schema , progress : Option [ProgressFor ]): MetaDataValidation [Any ] = {
14181
14282 val separator = schema.globalDirectives.collectFirst {
0 commit comments