Changeset 9655 for branches/HivePerformance/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3
- Timestamp:
- 06/24/13 20:22:11 (12 years ago)
- Location:
- branches/HivePerformance/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources
- Property svn:mergeinfo changed
/trunk/sources merged: 9618,9623-9624,9626,9647-9649,9652
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis merged: 9652
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TableFileParser.cs
r9616 r9655 28 28 using System.Linq; 29 29 using System.Runtime.Serialization; 30 using System.Text;31 30 32 31 namespace HeuristicLab.Problems.Instances.DataAnalysis { 33 32 public class TableFileParser { 34 33 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 }; 36 37 private Tokenizer tokenizer; 37 38 private List<List<object>> rowValues; … … 360 361 361 362 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) { 368 376 yield return INTERNAL_SEPARATOR; 369 } else {370 subStr.Append(c);371 377 } 372 378 } 373 yield return subStr.ToString();374 379 } 375 380
Note: See TracChangeset
for help on using the changeset viewer.