Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9753 for stable


Ignore:
Timestamp:
07/25/13 10:22:57 (11 years ago)
Author:
mkommend
Message:

#2047: Integrated r9652 in the stable branch.

Location:
stable
Files:
5 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/DataAnalysisImportTypeDialog.cs

    r9651 r9753  
    4242      new KeyValuePair<char, string>(';', "; (Semicolon)" ),
    4343      new KeyValuePair<char, string>(',', ", (Comma)" ),   
    44       new KeyValuePair<char, string>('\t', "\\t (Tab)")
     44      new KeyValuePair<char, string>('\t', "\\t (Tab)"),
     45      new KeyValuePair<char, string>((char)0, "all whitespaces (including tabs and spaces)")
    4546    };
    4647
  • stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TableFileParser.cs

    r9651 r9753  
    2828using System.Linq;
    2929using System.Runtime.Serialization;
    30 using System.Text;
    3130
    3231namespace HeuristicLab.Problems.Instances.DataAnalysis {
    3332  public class TableFileParser {
    3433    private const int BUFFER_SIZE = 65536;
    35     private static readonly char[] POSSIBLE_SEPARATORS = new char[] { ',', ';', '\t' };
     34    // char used to symbolize whitespaces (no missing values can be handled with whitespaces)
     35    private const char WHITESPACECHAR = (char)0;
     36    private static readonly char[] POSSIBLE_SEPARATORS = new char[] { ',', ';', '\t', WHITESPACECHAR };
    3637    private Tokenizer tokenizer;
    3738    private List<List<object>> rowValues;
     
    360361
    361362      private IEnumerable<string> Split(string line) {
    362         StringBuilder subStr = new StringBuilder();
    363         foreach (char c in line) {
    364           if (c == separator) {
    365             yield return subStr.ToString();
    366             subStr = new StringBuilder();
    367             // all separator characters are transformed to the internally used separator character
     363        IEnumerable<string> splitString;
     364        if (separator == WHITESPACECHAR) {
     365          //separate whitespaces
     366          splitString = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
     367        } else {
     368          splitString = line.Split(separator);
     369        }
     370        int cur = splitString.Count();
     371        foreach (var str in splitString) {
     372          yield return str;
     373          cur--;
     374          // do not return the INTERNAL_SEPARATOR after the last string
     375          if (cur != 0) {
    368376            yield return INTERNAL_SEPARATOR;
    369           } else {
    370             subStr.Append(c);
    371377          }
    372378        }
    373         yield return subStr.ToString();
    374379      }
    375380
Note: See TracChangeset for help on using the changeset viewer.