Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/29/15 16:59:52 (9 years ago)
Author:
gkronber
Message:

#2071: added progress reporting when importing regression problem data from csv files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TableFileParser.cs

    r13413 r13414  
    3030
    3131namespace HeuristicLab.Problems.Instances.DataAnalysis {
    32   public class TableFileParser {
     32  public class TableFileParser : Progress<long> { // reports the number of bytes read
    3333    private const int BUFFER_SIZE = 65536;
    3434    // char used to symbolize whitespaces (no missing values can be handled with whitespaces)
     
    310310        private set { currentLine = value; }
    311311      }
     312      public long BytesRead {
     313        get;
     314        private set;
     315      }
     316
    312317
    313318      public Tokenizer(StreamReader reader, NumberFormatInfo numberFormatInfo, DateTimeFormatInfo dateTimeFormatInfo, char separator) {
     
    322327        if (!reader.EndOfStream) {
    323328          CurrentLine = reader.ReadLine();
     329          try {
     330            BytesRead = reader.BaseStream.Position;
     331          } catch (IOException) {
     332            BytesRead += CurrentLine.Length + 2; // guess
     333          } catch (NotSupportedException) {
     334            BytesRead += CurrentLine.Length + 2;
     335          }
    324336          int i = 0;
    325337          foreach (var tok in Split(CurrentLine)) {
     
    449461          rowValues.Add(row);
    450462        }
     463
     464        OnReport(tokenizer.BytesRead);
    451465      }
    452466    }
Note: See TracChangeset for help on using the changeset viewer.