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