fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. var csvString = "G9999999990001800002777107050,G9999999990002777107HMNLAQKPRLLHRAQRWJ010,1,3,29,P,6.74,11.23,07,P,5.25,14.29,08,P,6.89,16.92,07,P,5,4,";
  10.  
  11. var fields = csvString.Split(',');
  12. var selected = Enumerable.Range(4, fields.Length - 4) // 4 .. length-1
  13. .Where(i => i % 4 <= 1 ) // 4, 5, 8, 9, 12, 13, ...
  14. .Select(i => fields[i]);
  15.  
  16. Console.WriteLine(string.Join(" ", selected.ToArray()));
  17.  
  18. var selected2 = csvString.Split(',') // 4, 5, 8, 9, 12, 13, ...
  19. .Where((s,i) => i >= 4 && i % 4 <= 1);
  20.  
  21. Console.WriteLine(string.Join(" ", selected2.ToArray()));
  22. }
  23. }
  24.  
Success #stdin #stdout 0.03s 28116KB
stdin
Standard input is empty
stdout
29 P 07 P 08 P 07 P 
29 P 07 P 08 P 07 P