linq - how to sort csv file with two columns in c# -


There are 14 columns and ~ 800,000 lines in my CSV files, sorted according to 3 columns in order of CSV order 10th column Have to do. I use the code below but only 10th column

  string is from filePath = "D: \\ csv.csv"; String [] line = file. Readlines (file text, encoding.default); Var data = lines Skip (1); Var sorted = data Select (line = & gt; new {sort = int32.Parse (line.Split (';') [9]), line = line} .orderbie (x => x.SortKey). X = & gt; x line); File. WritAllLines ("D: \\ Sorted CSUCSV", take lines (1) .cockets (sorted), encoding. Default);   

My CSV preference

  • col1; cola2; col3; ......; col10; ..
  • ABC ; Fds; 123456; ....; 123; ..
  • deaf; dsa; 12435; .... 124; ..

      var sorted = data. Select ( Look up = & gt; New {SortKey = Int32.Parse (line.Split (';') [9]), SortKeyThenBy = Int32.Parse (line.Split (';') [2]), line = line}) (X = & gt; X.SortKey). Then (x => x.SortKeyThenBy)    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -