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/Classification/CSV/ClassifiactionCSVInstanceProvider.cs

    r8211 r8530  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Globalization;
    2425using System.IO;
    2526using System.Linq;
     
    8687    }
    8788    public override void ExportData(IClassificationProblemData instance, string path) {
    88       StringBuilder strBuilder = new StringBuilder();
     89      var strBuilder = new StringBuilder();
    8990
    9091      foreach (var variable in instance.InputVariables) {
    91         strBuilder.Append(variable + ";");
     92        strBuilder.Append(variable + CultureInfo.CurrentCulture.TextInfo.ListSeparator);
    9293      }
    93       strBuilder.Remove(strBuilder.Length - 1, 1);
     94      strBuilder.Remove(strBuilder.Length - CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length, CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length);
    9495      strBuilder.AppendLine();
    9596
    96       Dataset dataset = instance.Dataset;
     97      var dataset = instance.Dataset;
    9798
    9899      for (int i = 0; i < dataset.Rows; i++) {
    99100        for (int j = 0; j < dataset.Columns; j++) {
    100           strBuilder.Append(dataset.GetValue(i, j) + ";");
     101          if (j > 0) strBuilder.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
     102          strBuilder.Append(dataset.GetValue(i, j));
    101103        }
    102         strBuilder.Remove(strBuilder.Length - 1, 1);
    103104        strBuilder.AppendLine();
    104105      }
    105106
    106       using (StreamWriter writer = new StreamWriter(path)) {
     107      using (var writer = new StreamWriter(path)) {
    107108        writer.Write(strBuilder);
    108109      }
Note: See TracChangeset for help on using the changeset viewer.