Reputation: 41
I'm quite new to C# so excuse me for the newbie Q...
I have a comma-delimited file with about 500 lines that looks like this: http://pastebin.com/JZyswTNX
I want to first import the file to my program, and then parse it into a 2-dimensional array of numbers rounded to 2 digits after the dot.
After that, i want to read only the last 20 lines of the txt file. I prefer not to hard-code "go to line 480" because I'm not sure each file will have the same amount of lines.
What would be the easiest way to do that? (some built ins maybe?)
Upvotes: 0
Views: 518
Reputation: 5488
You can use File.ReadAllLines
which returns array of strings.
Then you can split this array by comma
var lines = File.ReadAllLines (path);
var result = lines.Select (x=>x.Split (','));
result
is two dimensional array
Upvotes: 1