Yeah, the C# code looks pretty clean.And here is the code in C# :
var contents =File.ReadAllText(filename).Split('\n');
var csv =from line in contents select line.Split(',').ToArray();
(you can actually move that all into one line but it looks ugly)
P.S.: This version is most likely a lot faster than Python's Pandas. I know OP asked about a Python solution but I could not help it but jump in after seeing 3 full pages of discussion how to read in a text file.
Python doesn't have a decent method for handling csv files "out of the box", probably because most ppl end up using libraries to get the job done... I've noticed that the Python community doesn't have such as strong drive to integrate functionality from the libraries into the main program as you find in other communities (like C++ that keeps absorbing parts of BOOST on every revision)
You may be right about the speed, specially if the files are large and python starts hoggin memory... it may hold it's time against C# on small files but once it starts hogging memory then it can slow down to a crawl.
I had a project a few months ago where I had to parse through files with 10-15 million lines of untidy quotes data and it got to a point where python was taking far longer than my patience allowed for going through 1 file (I killed it at round 30 minutes) and sucking all my memory and a big chunk of swap too...
I moved the project to C and by the time it was done it was going through the files in about 1 minute using 2-3 % memory per core.
