Skip to main content


Showing posts from 2009

Reading a CSV file into a DataTable

If you don't share my opinion that CSV should be banned by an international convention, it might be because you've never had to write code to read a CSV file. "Ah, but thats easy", you say, "Just use String.Split()". Well, that will work if your CSV file is an academic example that doesn't contain strings that were typed by real human beings. But real-world CSV files generally contain some or all of the following horrors: - some strings enclosed in speechmarks, but some not - empty fields - speechmarks within strings - commas within strings - carriage returns within strings To demonstrate, here is a CSV example that exhibits all of the traits listed above: "First Name","Last Name","Address","Town","Postcode" David,O'Leary,"12 Acacia Avenue",London,NW5 3DF June,Robinson,"14, Abbey Court","Putney",SW6 4FG Greg,Hampton,"",, Stephen,James,""&qu


I've spent the last couple of weeks hanging out on StackOverflow , and thinking about how successful its design is. Incase you haven't heard of it, StackOverflow is a question-and-answer site for programmers, put together by two popular programming bloggers, Joel Spolsky and Jeff Atwood . Participants get given 'reputation points' when their questions or answers are voted-up by other people. This makes the site very useful because when you ask a question there are loads of programmers online practically falling over each other to answer your question. I guess programmers all like to get positive feedback from their peers, and thats what the vote system provides. The reputation system is just one design point out of several that Joel and Jeff obviously thought very carfully about when building the site. A few weeks ago Joel gave a googletech talk about StackOverflow, going into detail about how they designed it: He makes the interesting point in this video that H