/// <summary> /// Read the headers. /// </summary> /// <param name="format">The format of this CSV file.</param> /// <param name="headers">Are headers present.</param> private void Begin(bool headers, CSVFormat format) { try { DateFormat = "yyyy-MM-dd"; TimeFormat = "HHmmss"; this.parseLine = new ParseCSVLine(format); // read the column heads if (headers) { String line = _reader.ReadLine(); IList <String> tok = parseLine.Parse(line); int i = 0; foreach (String header in tok) { if (_columns.ContainsKey(header.ToLower())) { throw new EncogError("Two columns cannot have the same name"); } _columns.Add(header.ToLower(), i++); _columnNames.Add(header); } } _data = null; } catch (IOException e) { #if logging if (logger.IsErrorEnabled) { logger.Error("Exception", e); } #endif throw new EncogError(e); } }
/// <summary> /// Read the headers. /// </summary> /// <param name="format">The format of this CSV file.</param> /// <param name="headers">Are headers present.</param> private void Begin(bool headers, CSVFormat format) { try { DateFormat = "yyyy-MM-dd"; TimeFormat = "HHmmss"; this.parseLine = new ParseCSVLine(format); // read the column heads if (headers) { String line = _reader.ReadLine(); IList<String> tok = parseLine.Parse(line); int i = 0; foreach (String header in tok) { if (_columns.ContainsKey(header.ToLower())) throw new EncogError("Two columns cannot have the same name"); _columns.Add(header.ToLower(), i++); _columnNames.Add(header); } } _data = null; } catch (IOException e) { #if logging if (logger.IsErrorEnabled) { logger.Error("Exception", e); } #endif throw new EncogError(e); } }
/// <summary> /// Count the columns and create a an array to hold them. /// </summary> /// <param name="line">One line from the file</param> private void InitData(string line) { IList <String> tok = parseLine.Parse(line); _data = new String[tok.Count]; }