Created
April 5, 2014 15:27
-
-
Save kamiyaowl/9993394 to your computer and use it in GitHub Desktop.
c# read csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30,12,55,13,32,7,25,44,14,36,20,22,2,10,46,29,33,59,38,0,74,61,72,34,35,6,78,5,23,28,1,4,93,3,42,82,17,19,8,66,51,65,26,11,54,31,16,9,39,57,56,43,83,62,99,18,75,68,49,89,21,48,60,50,47,71,69,91,15,58,94,92,90,52,41,79,64,37,27,98,85,73,40,81,80,95,77,67,97,86,53,70,24,76,84,96,63,45,88,87, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.IO; | |
using System.Text; | |
using System.Collections.Generic; | |
static class Extension { | |
public static IEnumerable<int> CreateSource(this string[] src) { | |
return src.SelectMany(x => x.Split(',')).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => int.Parse(x)); | |
} | |
public static void ForEach<T>(this IEnumerable<T> src, Action<T> f) { | |
foreach (var s in src) | |
f(s); | |
} | |
static void Main() { | |
File.ReadAllLines("Src.csv").CreateSource().ForEach(x => Console.Write("{0},",x)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 | 12 | 55 | 13 | 32 | 7 | 25 | 44 | 14 | 36 | ||
---|---|---|---|---|---|---|---|---|---|---|---|
20 | 22 | 2 | 10 | 46 | 29 | 33 | 59 | 38 | 0 | ||
74 | 61 | 72 | 34 | 35 | 6 | 78 | 5 | 23 | 28 | ||
1 | 4 | 93 | 3 | 42 | 82 | 17 | 19 | 8 | 66 | ||
51 | 65 | 26 | 11 | 54 | 31 | 16 | 9 | 39 | 57 | ||
56 | 43 | 83 | 62 | 99 | 18 | 75 | 68 | 49 | 89 | ||
21 | 48 | 60 | 50 | 47 | 71 | 69 | 91 | 15 | 58 | ||
94 | 92 | 90 | 52 | 41 | 79 | 64 | 37 | 27 | 98 | ||
85 | 73 | 40 | 81 | 80 | 95 | 77 | 67 | 97 | 86 | ||
53 | 70 | 24 | 76 | 84 | 96 | 63 | 45 | 88 | 87 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you, this was helpful.