Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8530 for trunk/sources


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

Location:
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3
Files:
3 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      }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r8211 r8530  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Globalization;
    2425using System.IO;
    2526using System.Text;
     
    8586
    8687      foreach (var variable in instance.InputVariables) {
    87         strBuilder.Append(variable + ";");
     88        strBuilder.Append(variable + CultureInfo.CurrentCulture.TextInfo.ListSeparator);
    8889      }
    89       strBuilder.Remove(strBuilder.Length - 1, 1);
     90      strBuilder.Remove(strBuilder.Length - CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length, CultureInfo.CurrentCulture.TextInfo.ListSeparator.Length);
    9091      strBuilder.AppendLine();
    9192
     
    9495      for (int i = 0; i < dataset.Rows; i++) {
    9596        for (int j = 0; j < dataset.Columns; j++) {
    96           strBuilder.Append(dataset.GetValue(i, j) + ";");
     97          if (j > 0) strBuilder.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
     98          strBuilder.Append(dataset.GetValue(i, j));
    9799        }
    98         strBuilder.Remove(strBuilder.Length - 1, 1);
    99100        strBuilder.AppendLine();
    100101      }
  • 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.