Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9651


Ignore:
Timestamp:
06/23/13 23:00:30 (12 years ago)
Author:
mkommend
Message:

#2070: Merged r9608, r9610, r9611, r9623, and r9624 in the stable branch.

Location:
stable
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.Instances.DataAnalysis

  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views

  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/ClassificationImportTypeDialog.Designer.cs

    r9456 r9651  
    6262      // OkButton
    6363      //
    64       this.OkButton.Location = new System.Drawing.Point(303, 464);
     64      this.OkButton.Location = new System.Drawing.Point(303, 482);
    6565      //
    6666      // TrainingTestTrackBar
     
    7878      // CancelationButton
    7979      //
    80       this.CancelationButton.Location = new System.Drawing.Point(384, 464);
     80      this.CancelationButton.Location = new System.Drawing.Point(384, 482);
    8181      //
    8282      // ProblemDataSettingsGroupBox
     
    8787      this.ProblemDataSettingsGroupBox.Controls.Add(this.TargetVariableComboBox);
    8888      this.ProblemDataSettingsGroupBox.Controls.Add(this.UniformDistributionOfClassesCheckbox);
    89       this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 315);
     89      this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 312);
    9090      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.UniformDistributionOfClassesCheckbox, 0);
    9191      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.TargetVariableComboBox, 0);
     
    110110      //
    111111      this.PreviewDatasetMatrix.Location = new System.Drawing.Point(6, 134);
    112       this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 175);
     112      this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 172);
    113113      //
    114114      // PreviewLabel
     
    118118      // TargetVariableComboBox
    119119      //
    120       this.TargetVariableComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     120      this.TargetVariableComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    121121            | System.Windows.Forms.AnchorStyles.Right)));
    122122      this.TargetVariableComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    178178      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    179179      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    180       this.ClientSize = new System.Drawing.Size(471, 499);
     180      this.ClientSize = new System.Drawing.Size(471, 517);
    181181      this.Name = "ClassificationImportTypeDialog";
    182182      this.Text = "Classification CSV Import";
  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.Designer.cs

    r9456 r9651  
    7272      this.PreviewDatasetMatrix = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    7373      this.ToolTip = new System.Windows.Forms.ToolTip(this.components);
     74      this.CheckboxColumnNames = new System.Windows.Forms.CheckBox();
    7475      ((System.ComponentModel.ISupportInitialize)(this.TrainingTestTrackBar)).BeginInit();
    7576      this.CSVSettingsGroupBox.SuspendLayout();
     
    9394      this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    9495      this.OkButton.Enabled = false;
    95       this.OkButton.Location = new System.Drawing.Point(303, 407);
     96      this.OkButton.Location = new System.Drawing.Point(303, 422);
    9697      this.OkButton.Name = "OkButton";
    9798      this.OkButton.Size = new System.Drawing.Size(75, 23);
     
    102103      // TrainingTestTrackBar
    103104      //
    104       this.TrainingTestTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     105      this.TrainingTestTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    105106            | System.Windows.Forms.AnchorStyles.Right)));
    106107      this.TrainingTestTrackBar.Location = new System.Drawing.Point(6, 43);
     
    137138      this.CancelationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    138139      this.CancelationButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    139       this.CancelationButton.Location = new System.Drawing.Point(384, 407);
     140      this.CancelationButton.Location = new System.Drawing.Point(384, 422);
    140141      this.CancelationButton.Name = "CancelationButton";
    141142      this.CancelationButton.Size = new System.Drawing.Size(75, 23);
     
    166167      // ProblemTextBox
    167168      //
    168       this.ProblemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     169      this.ProblemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    169170            | System.Windows.Forms.AnchorStyles.Right)));
    170171      this.ProblemTextBox.Location = new System.Drawing.Point(91, 6);
     
    180181      // DateTimeFormatComboBox
    181182      //
    182       this.DateTimeFormatComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     183      this.DateTimeFormatComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    183184            | System.Windows.Forms.AnchorStyles.Right)));
    184185      this.DateTimeFormatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    193194      // DecimalSeparatorComboBox
    194195      //
    195       this.DecimalSeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     196      this.DecimalSeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    196197            | System.Windows.Forms.AnchorStyles.Right)));
    197198      this.DecimalSeparatorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    233234      // SeparatorComboBox
    234235      //
    235       this.SeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     236      this.SeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    236237            | System.Windows.Forms.AnchorStyles.Right)));
    237238      this.SeparatorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    246247      // CSVSettingsGroupBox
    247248      //
    248       this.CSVSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    249             | System.Windows.Forms.AnchorStyles.Right)));
     249      this.CSVSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     250            | System.Windows.Forms.AnchorStyles.Right)));
     251      this.CSVSettingsGroupBox.Controls.Add(this.CheckboxColumnNames);
    250252      this.CSVSettingsGroupBox.Controls.Add(this.DateTimeFormatInfoLabel);
    251253      this.CSVSettingsGroupBox.Controls.Add(this.DecimalSeparatorInfoLabel);
     
    259261      this.CSVSettingsGroupBox.Location = new System.Drawing.Point(12, 32);
    260262      this.CSVSettingsGroupBox.Name = "CSVSettingsGroupBox";
    261       this.CSVSettingsGroupBox.Size = new System.Drawing.Size(447, 105);
     263      this.CSVSettingsGroupBox.Size = new System.Drawing.Size(447, 126);
    262264      this.CSVSettingsGroupBox.TabIndex = 16;
    263265      this.CSVSettingsGroupBox.TabStop = false;
     
    302304      // ProblemDataSettingsGroupBox
    303305      //
    304       this.ProblemDataSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    305             | System.Windows.Forms.AnchorStyles.Left) 
     306      this.ProblemDataSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     307            | System.Windows.Forms.AnchorStyles.Left)
    306308            | System.Windows.Forms.AnchorStyles.Right)));
    307309      this.ProblemDataSettingsGroupBox.Controls.Add(this.ErrorTextBox);
     
    313315      this.ProblemDataSettingsGroupBox.Controls.Add(this.TrainingTestTrackBar);
    314316      this.ProblemDataSettingsGroupBox.Controls.Add(this.ShuffleDataCheckbox);
    315       this.ProblemDataSettingsGroupBox.Location = new System.Drawing.Point(12, 143);
     317      this.ProblemDataSettingsGroupBox.Location = new System.Drawing.Point(12, 164);
    316318      this.ProblemDataSettingsGroupBox.Name = "ProblemDataSettingsGroupBox";
    317       this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 258);
     319      this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 252);
    318320      this.ProblemDataSettingsGroupBox.TabIndex = 17;
    319321      this.ProblemDataSettingsGroupBox.TabStop = false;
     
    322324      // ErrorTextBox
    323325      //
     326      this.ErrorTextBox.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
    324327      this.ErrorTextBox.Location = new System.Drawing.Point(6, 15);
    325328      this.ErrorTextBox.Multiline = true;
     
    352355      // PreviewDatasetMatrix
    353356      //
    354       this.PreviewDatasetMatrix.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    355             | System.Windows.Forms.AnchorStyles.Left) 
     357      this.PreviewDatasetMatrix.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     358            | System.Windows.Forms.AnchorStyles.Left)
    356359            | System.Windows.Forms.AnchorStyles.Right)));
    357360      this.PreviewDatasetMatrix.Caption = "Dataset Preview";
     
    362365      this.PreviewDatasetMatrix.ShowRowsAndColumnsTextBox = false;
    363366      this.PreviewDatasetMatrix.ShowStatisticalInformation = false;
    364       this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 144);
     367      this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 138);
    365368      this.PreviewDatasetMatrix.TabIndex = 0;
     369      //
     370      // CheckboxColumnNames
     371      //
     372      this.CheckboxColumnNames.AutoSize = true;
     373      this.CheckboxColumnNames.Location = new System.Drawing.Point(9, 103);
     374      this.CheckboxColumnNames.Name = "CheckboxColumnNames";
     375      this.CheckboxColumnNames.Size = new System.Drawing.Size(144, 17);
     376      this.CheckboxColumnNames.TabIndex = 24;
     377      this.CheckboxColumnNames.Text = "Column names in first line";
     378      this.CheckboxColumnNames.UseVisualStyleBackColor = true;
     379      this.CheckboxColumnNames.CheckedChanged += new System.EventHandler(this.CheckboxColumnNames_CheckedChanged);
    366380      //
    367381      // DataAnalysisImportTypeDialog
     
    370384      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    371385      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    372       this.ClientSize = new System.Drawing.Size(471, 442);
     386      this.ClientSize = new System.Drawing.Size(471, 457);
    373387      this.Controls.Add(this.ProblemDataSettingsGroupBox);
    374388      this.Controls.Add(this.CSVSettingsGroupBox);
     
    422436    protected System.Windows.Forms.Label ShuffelInfoLabel;
    423437    protected System.Windows.Forms.ToolTip ToolTip;
     438    private System.Windows.Forms.CheckBox CheckboxColumnNames;
    424439  }
    425440}
  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.cs

    r9458 r9651  
    6868          Separator = (char)SeparatorComboBox.SelectedValue,
    6969          NumberFormatInfo = (NumberFormatInfo)DecimalSeparatorComboBox.SelectedValue,
    70           DateTimeFormatInfo = (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue
     70          DateTimeFormatInfo = (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue,
     71          VariableNamesAvailable = CheckboxColumnNames.Checked
    7172        };
    7273      }
     
    99100      DateTimeFormatComboBox.Enabled = true;
    100101      ProblemTextBox.Text = openFileDialog.FileName;
     102      TableFileParser csvParser = new TableFileParser();
     103      CheckboxColumnNames.Checked = csvParser.AreColumnNamesInFirstLine(ProblemTextBox.Text,
     104                                                                      (NumberFormatInfo)DecimalSeparatorComboBox.SelectedValue,
     105                                                                      (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue,
     106                                                                      (char)SeparatorComboBox.SelectedValue);
    101107      ParseCSVFile();
    102108    }
    103109
    104110    protected virtual void CSVFormatComboBoxSelectionChangeCommitted(object sender, EventArgs e) {
     111      if (string.IsNullOrEmpty(ProblemTextBox.Text)) return;
     112
     113      ParseCSVFile();
     114    }
     115
     116    protected virtual void CheckboxColumnNames_CheckedChanged(object sender, EventArgs e) {
    105117      if (string.IsNullOrEmpty(ProblemTextBox.Text)) return;
    106118
     
    115127                        (NumberFormatInfo)DecimalSeparatorComboBox.SelectedValue,
    116128                        (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue,
    117                         (char)SeparatorComboBox.SelectedValue);
     129                        (char)SeparatorComboBox.SelectedValue,
     130                        CheckboxColumnNames.Checked);
    118131        IEnumerable<string> variableNamesWithType = GetVariableNamesWithType(csvParser);
    119132        PreviewDatasetMatrix.Content = new Dataset(variableNamesWithType, csvParser.Values);
  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionImportTypeDialog.Designer.cs

    r9456 r9651  
    5353      this.SuspendLayout();
    5454      //
     55      // OkButton
     56      //
     57      this.OkButton.Location = new System.Drawing.Point(303, 421);
     58      //
     59      // CancelationButton
     60      //
     61      this.CancelationButton.Location = new System.Drawing.Point(384, 421);
     62      //
    5563      // ProblemDataSettingsGroupBox
    5664      //
     
    5866      this.ProblemDataSettingsGroupBox.Controls.Add(this.TargetVariableLabel);
    5967      this.ProblemDataSettingsGroupBox.Controls.Add(this.TargetVariableComboBox);
     68      this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 251);
    6069      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.PreviewLabel, 0);
    6170      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.ShuffelInfoLabel, 0);
     
    106115      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    107116      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    108       this.ClientSize = new System.Drawing.Size(471, 442);
     117      this.ClientSize = new System.Drawing.Size(471, 456);
    109118      this.Name = "RegressionImportTypeDialog";
    110119      this.Text = "Regression CSV Import";
  • stable/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/TimeSeriesPrognosisImportTypeDialog.Designer.cs

    r9456 r9651  
    5959      this.ShuffleDataCheckbox.Visible = false;
    6060      //
     61      // OkButton
     62      //
     63      this.OkButton.Location = new System.Drawing.Point(303, 407);
     64      //
     65      // CancelationButton
     66      //
     67      this.CancelationButton.Location = new System.Drawing.Point(384, 407);
     68      //
    6169      // ProblemDataSettingsGroupBox
    6270      //
     
    6472      this.ProblemDataSettingsGroupBox.Controls.Add(this.TargetVariableComboBox);
    6573      this.ProblemDataSettingsGroupBox.Controls.Add(this.TargetVariableLabel);
     74      this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 237);
    6675      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.ShuffleDataCheckbox, 0);
    6776      this.ProblemDataSettingsGroupBox.Controls.SetChildIndex(this.TargetVariableLabel, 0);
     
    8089      this.ErrorTextBox.Location = new System.Drawing.Point(6, 19);
    8190      this.ErrorTextBox.Size = new System.Drawing.Size(435, 69);
     91      //
     92      // PreviewDatasetMatrix
     93      //
     94      this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 123);
    8295      //
    8396      // SeparatorInfoLabel
     
    101114      // TargetVariableComboBox
    102115      //
    103       this.TargetVariableComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     116      this.TargetVariableComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    104117            | System.Windows.Forms.AnchorStyles.Right)));
    105118      this.TargetVariableComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV/ClassifiactionCSVInstanceProvider.cs

    r9456 r9651  
    5959      TableFileParser csvFileParser = new TableFileParser();
    6060
    61       csvFileParser.Parse(path);
     61      csvFileParser.Parse(path, csvFileParser.AreColumnNamesInFirstLine(path));
    6262
    6363      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ResourceClassificationInstanceProvider.cs

    r9456 r9651  
    4949        TableFileParser csvFileParser = new TableFileParser();
    5050        using (Stream stream = instancesZipFile.GetInputStream(entry)) {
    51           csvFileParser.Parse(stream, numberFormat, dateFormat, separator);
     51          csvFileParser.Parse(stream, numberFormat, dateFormat, separator, true);
    5252        }
    5353
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r9456 r9651  
    5858    public override IClusteringProblemData ImportData(string path) {
    5959      var csvFileParser = new TableFileParser();
    60       csvFileParser.Parse(path);
     60      csvFileParser.Parse(path, csvFileParser.AreColumnNamesInFirstLine(path));
    6161
    6262      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisCSVFormat.cs

    r9456 r9651  
    2727    public NumberFormatInfo NumberFormatInfo { get; set; }
    2828    public DateTimeFormatInfo DateTimeFormatInfo { get; set; }
     29    public bool VariableNamesAvailable { get; set; }
    2930  }
    3031}
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisInstanceProvider.cs

    r9456 r9651  
    3838    public TData ImportData(string path, ImportType type, DataAnalysisCSVFormat csvFormat) {
    3939      TableFileParser csvFileParser = new TableFileParser();
    40       csvFileParser.Parse(path, csvFormat.NumberFormatInfo, csvFormat.DateTimeFormatInfo, csvFormat.Separator);
     40      csvFileParser.Parse(path, csvFormat.NumberFormatInfo, csvFormat.DateTimeFormatInfo, csvFormat.Separator, csvFormat.VariableNamesAvailable);
    4141      return ImportData(path, type, csvFileParser);
    4242    }
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs

    r9456 r9651  
    5757    public override IRegressionProblemData ImportData(string path) {
    5858      TableFileParser csvFileParser = new TableFileParser();
    59       csvFileParser.Parse(path);
     59      csvFileParser.Parse(path, csvFileParser.AreColumnNamesInFirstLine(path));
    6060
    6161      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ResourceRegressionInstanceProvider.cs

    r9456 r9651  
    4949        TableFileParser csvFileParser = new TableFileParser();
    5050        using (Stream stream = instancesZipFile.GetInputStream(entry)) {
    51           csvFileParser.Parse(stream, numberFormat, dateFormat, separator);
     51          csvFileParser.Parse(stream, numberFormat, dateFormat, separator, true);
    5252        }
    5353
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TableFileParser.cs

    r9457 r9651  
    7575    }
    7676
     77    public bool AreColumnNamesInFirstLine(string fileName) {
     78      NumberFormatInfo numberFormat;
     79      DateTimeFormatInfo dateTimeFormatInfo;
     80      char separator;
     81      DetermineFileFormat(fileName, out numberFormat, out dateTimeFormatInfo, out separator);
     82      using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
     83        return AreColumnNamesInFirstLine(stream, numberFormat, dateTimeFormatInfo, separator);
     84      }
     85    }
     86
     87    public bool AreColumnNamesInFirstLine(Stream stream) {
     88      NumberFormatInfo numberFormat = NumberFormatInfo.InvariantInfo;
     89      DateTimeFormatInfo dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo;
     90      char separator = ',';
     91      return AreColumnNamesInFirstLine(stream, numberFormat, dateTimeFormatInfo, separator);
     92    }
     93
     94    public bool AreColumnNamesInFirstLine(string fileName, NumberFormatInfo numberFormat,
     95                                         DateTimeFormatInfo dateTimeFormatInfo, char separator) {
     96      using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
     97        return AreColumnNamesInFirstLine(stream, numberFormat, dateTimeFormatInfo, separator);
     98      }
     99    }
     100
     101    public bool AreColumnNamesInFirstLine(Stream stream, NumberFormatInfo numberFormat,
     102                                          DateTimeFormatInfo dateTimeFormatInfo, char separator) {
     103      using (StreamReader reader = new StreamReader(stream)) {
     104        tokenizer = new Tokenizer(reader, numberFormat, dateTimeFormatInfo, separator);
     105        return tokenizer.Peek().type != TokenTypeEnum.Double;
     106      }
     107    }
     108
    77109    /// <summary>
    78110    /// Parses a file and determines the format first
    79111    /// </summary>
    80112    /// <param name="fileName">file which is parsed</param>
    81     public void Parse(string fileName) {
     113    /// <param name="columnNamesInFirstLine"></param>
     114    public void Parse(string fileName, bool columnNamesInFirstLine) {
    82115      NumberFormatInfo numberFormat;
    83116      DateTimeFormatInfo dateTimeFormatInfo;
    84117      char separator;
    85       DetermineFileFormat(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), out numberFormat, out dateTimeFormatInfo, out separator);
    86       Parse(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), numberFormat, dateTimeFormatInfo, separator);
     118      DetermineFileFormat(fileName, out numberFormat, out dateTimeFormatInfo, out separator);
     119      Parse(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), numberFormat, dateTimeFormatInfo, separator, columnNamesInFirstLine);
    87120    }
    88121
     
    94127    /// <param name="dateTimeFormatInfo">Format of datetime</param>
    95128    /// <param name="separator">defines the separator</param>
    96     public void Parse(string fileName, NumberFormatInfo numberFormat, DateTimeFormatInfo dateTimeFormatInfo, char separator) {
    97       Parse(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), numberFormat, dateTimeFormatInfo, separator);
     129    /// <param name="columnNamesInFirstLine"></param>
     130    public void Parse(string fileName, NumberFormatInfo numberFormat, DateTimeFormatInfo dateTimeFormatInfo, char separator, bool columnNamesInFirstLine) {
     131      using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
     132        Parse(stream, numberFormat, dateTimeFormatInfo, separator, columnNamesInFirstLine);
     133      }
    98134    }
    99135
     
    102138    /// </summary>
    103139    /// <param name="stream">stream which is parsed</param>
    104     public void Parse(Stream stream) {
     140    /// <param name="columnNamesInFirstLine"></param>
     141    public void Parse(Stream stream, bool columnNamesInFirstLine) {
    105142      NumberFormatInfo numberFormat = NumberFormatInfo.InvariantInfo;
    106143      DateTimeFormatInfo dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo;
    107144      char separator = ',';
    108       Parse(stream, numberFormat, dateTimeFormatInfo, separator);
     145      Parse(stream, numberFormat, dateTimeFormatInfo, separator, columnNamesInFirstLine);
    109146    }
    110147
     
    116153    /// <param name="dateTimeFormatInfo">Format of datetime</param>
    117154    /// <param name="separator">defines the separator</param>
    118     public void Parse(Stream stream, NumberFormatInfo numberFormat, DateTimeFormatInfo dateTimeFormatInfo, char separator) {
     155    /// <param name="columnNamesInFirstLine"></param>
     156    public void Parse(Stream stream, NumberFormatInfo numberFormat, DateTimeFormatInfo dateTimeFormatInfo, char separator, bool columnNamesInFirstLine) {
    119157      using (StreamReader reader = new StreamReader(stream)) {
    120158        tokenizer = new Tokenizer(reader, numberFormat, dateTimeFormatInfo, separator);
    121159        // parse the file
    122         Parse();
     160        Parse(columnNamesInFirstLine);
    123161      }
    124162
     
    372410
    373411    #region parsing
    374     private void Parse() {
    375       ParseVariableNames();
    376       if (!tokenizer.HasNext()) Error("Couldn't parse data values. Probably because of incorrect number format (the parser expects english number format with a '.' as decimal separator).", "", tokenizer.CurrentLineNumber);
     412    private void Parse(bool columnNamesInFirstLine) {
     413      if (columnNamesInFirstLine) {
     414        ParseVariableNames();
     415        if (!tokenizer.HasNext())
     416          Error(
     417            "Couldn't parse data values. Probably because of incorrect number format (the parser expects english number format with a '.' as decimal separator).",
     418            "", tokenizer.CurrentLineNumber);
     419      }
    377420      ParseValues();
    378421      if (rowValues.Count == 0) Error("Couldn't parse data values. Probably because of incorrect number format (the parser expects english number format with a '.' as decimal separator).", "", tokenizer.CurrentLineNumber);
     
    423466
    424467    private void ParseVariableNames() {
    425       //if first token is double no variables names are given
    426       if (tokenizer.Peek().type == TokenTypeEnum.Double) return;
    427 
    428468      // the first line must contain variable names
    429469      List<Token> tokens = new List<Token>();
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TimeSeries/CSV/TimeSeriesPrognosisCSVInstanceProvider.cs

    r9456 r9651  
    5757    public override ITimeSeriesPrognosisProblemData ImportData(string path) {
    5858      TableFileParser csvFileParser = new TableFileParser();
    59       csvFileParser.Parse(path);
     59      csvFileParser.Parse(path, csvFileParser.AreColumnNamesInFirstLine(path));
    6060
    6161      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
  • stable/HeuristicLab.Tests

  • stable/HeuristicLab.Tests/HeuristicLab.Problems.Instances.DataAnalysis-3.3/TableFileParserTest.cs

    r9456 r9651  
    4242      TableFileParser parser = new TableFileParser();
    4343      try {
    44         parser.Parse(tempFileName);
     44        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    4545        Assert.AreEqual(6, parser.Rows);
    4646        Assert.AreEqual(4, parser.Columns);
     
    6464      TableFileParser parser = new TableFileParser();
    6565      try {
    66         parser.Parse(tempFileName);
     66        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    6767        Assert.AreEqual(6, parser.Rows);
    6868        Assert.AreEqual(4, parser.Columns);
     
    8686      TableFileParser parser = new TableFileParser();
    8787      try {
    88         parser.Parse(tempFileName);
     88        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    8989        Assert.AreEqual(6, parser.Rows);
    9090        Assert.AreEqual(4, parser.Columns);
     
    109109      TableFileParser parser = new TableFileParser();
    110110      try {
    111         parser.Parse(tempFileName);
     111        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    112112        Assert.AreEqual(6, parser.Rows);
    113113        Assert.AreEqual(4, parser.Columns);
     
    131131      TableFileParser parser = new TableFileParser();
    132132      try {
    133         parser.Parse(tempFileName);
     133        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    134134        Assert.AreEqual(6, parser.Rows);
    135135        Assert.AreEqual(4, parser.Columns);
     
    153153      TableFileParser parser = new TableFileParser();
    154154      try {
    155         parser.Parse(tempFileName);
     155        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    156156        Assert.AreEqual(6, parser.Rows);
    157157        Assert.AreEqual(4, parser.Columns);
     
    175175      TableFileParser parser = new TableFileParser();
    176176      try {
    177         parser.Parse(tempFileName);
     177        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    178178        Assert.AreEqual(6, parser.Rows);
    179179        Assert.AreEqual(4, parser.Columns);
     
    197197      TableFileParser parser = new TableFileParser();
    198198      try {
    199         parser.Parse(tempFileName);
     199        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    200200        Assert.AreEqual(6, parser.Rows);
    201201        Assert.AreEqual(4, parser.Columns);
     
    220220      TableFileParser parser = new TableFileParser();
    221221      try {
    222         parser.Parse(tempFileName);
     222        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    223223        Assert.AreEqual(6, parser.Rows);
    224224        Assert.AreEqual(4, parser.Columns);
     
    243243      TableFileParser parser = new TableFileParser();
    244244      try {
    245         parser.Parse(tempFileName);
     245        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    246246        Assert.AreEqual(6, parser.Rows);
    247247        Assert.AreEqual(4, parser.Columns);
     
    266266      TableFileParser parser = new TableFileParser();
    267267      try {
    268         parser.Parse(tempFileName);
     268        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    269269        Assert.AreEqual(6, parser.Rows);
    270270        Assert.AreEqual(4, parser.Columns);
     
    289289      TableFileParser parser = new TableFileParser();
    290290      try {
    291         parser.Parse(tempFileName);
     291        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    292292        Assert.AreEqual(6, parser.Rows);
    293293        Assert.AreEqual(4, parser.Columns);
     
    311311      TableFileParser parser = new TableFileParser();
    312312      try {
    313         parser.Parse(tempFileName);
     313        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    314314        Assert.AreEqual(6, parser.Rows);
    315315        Assert.AreEqual(4, parser.Columns);
     
    333333      TableFileParser parser = new TableFileParser();
    334334      try {
    335         parser.Parse(tempFileName);
     335        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    336336        Assert.AreEqual(6, parser.Rows);
    337337        Assert.AreEqual(4, parser.Columns);
     
    355355      TableFileParser parser = new TableFileParser();
    356356      try {
    357         parser.Parse(tempFileName);
     357        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    358358        Assert.AreEqual(6, parser.Rows);
    359359        Assert.AreEqual(4, parser.Columns);
     
    377377      TableFileParser parser = new TableFileParser();
    378378      try {
    379         parser.Parse(tempFileName);
     379        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    380380        Assert.AreEqual(6, parser.Rows);
    381381        Assert.AreEqual(4, parser.Columns);
     
    400400      TableFileParser parser = new TableFileParser();
    401401      try {
    402         parser.Parse(tempFileName);
     402        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    403403        Assert.AreEqual(4, parser.Rows);
    404404        Assert.AreEqual(4, parser.Columns);
     
    421421      TableFileParser parser = new TableFileParser();
    422422      try {
    423         parser.Parse(tempFileName);
     423        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    424424        Assert.AreEqual(6, parser.Rows);
    425425        Assert.AreEqual(4, parser.Columns);
     
    443443      TableFileParser parser = new TableFileParser();
    444444      try {
    445         parser.Parse(tempFileName);
     445        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    446446        Assert.AreEqual(6, parser.Rows);
    447447        Assert.AreEqual(4, parser.Columns);
     
    465465      TableFileParser parser = new TableFileParser();
    466466      try {
    467         parser.Parse(tempFileName);
     467        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    468468        Assert.AreEqual(6, parser.Rows);
    469469        Assert.AreEqual(4, parser.Columns);
     
    487487      TableFileParser parser = new TableFileParser();
    488488      try {
    489         parser.Parse(tempFileName);
     489        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    490490        Assert.AreEqual(6, parser.Rows);
    491491        Assert.AreEqual(4, parser.Columns);
     
    508508      TableFileParser parser = new TableFileParser();
    509509      try {
    510         parser.Parse(tempFileName);
     510        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    511511        Assert.AreEqual(3, parser.Rows);
    512512        Assert.AreEqual(4507, parser.Columns);
     
    529529      TableFileParser parser = new TableFileParser();
    530530      try {
    531         parser.Parse(tempFileName);
     531        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    532532        Assert.AreEqual(6, parser.Rows);
    533533        Assert.AreEqual(4, parser.Columns);
     
    551551      TableFileParser parser = new TableFileParser();
    552552      try {
    553         parser.Parse(tempFileName);
     553        parser.Parse(tempFileName, parser.AreColumnNamesInFirstLine(tempFileName));
    554554        Assert.AreEqual(6, parser.Rows);
    555555        Assert.AreEqual(4, parser.Columns);
Note: See TracChangeset for help on using the changeset viewer.