Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/28/12 11:48:05 (12 years ago)
Author:
abeham
Message:

#1922: Used the culture's defined list separator in CSV export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs

    r8211 r8530  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Globalization;
    2425using System.IO;
    2526using System.Linq;
     
    8586    }
    8687    public override void ExportData(IRegressionProblemData instance, string path) {
    87       StringBuilder strBuilder = new StringBuilder();
     88      var strBuilder = new StringBuilder();
    8889
    8990      foreach (var variable in instance.InputVariables) {
    90         strBuilder.Append(variable + ";");
     91        strBuilder.Append(variable + CultureInfo.CurrentCulture.TextInfo.ListSeparator);
    9192      }
    92       strBuilder.Remove(strBuilder.Length - 1, 1);
     93      strBuilder.Remove(strBuilder.Length - CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length, CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length);
    9394      strBuilder.AppendLine();
    9495
    95       Dataset dataset = instance.Dataset;
     96      var dataset = instance.Dataset;
    9697
    9798      for (int i = 0; i < dataset.Rows; i++) {
    9899        for (int j = 0; j < dataset.Columns; j++) {
    99           strBuilder.Append(dataset.GetValue(i, j) + ";");
     100          if (j > 0) strBuilder.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
     101          strBuilder.Append(dataset.GetValue(i, j));
    100102        }
    101         strBuilder.Remove(strBuilder.Length - 1, 1);
    102103        strBuilder.AppendLine();
    103104      }
    104105
    105       using (StreamWriter writer = new StreamWriter(path)) {
     106      using (var writer = new StreamWriter(path)) {
    106107        writer.Write(strBuilder);
    107108      }
Note: See TracChangeset for help on using the changeset viewer.