0

I'm looking for general UI advice on importing a CSV file. The UI is done in ASP.NET MVC3. When the user uploads the file I need to validate it and allow them to manually correct any errors within the browser before I store it in the database. There's so many potential errors to check for and I'm really not sure what the best way is to achieve this. Another thing is that I only have a few days to implement this so it can't be too complicated. I'm fine with regular expressions and programming and I already have the posted file stream available, but I just can't think of a good and practical way to present this functionaly to the user. Hope someone can inspire me. Many thanks.

Mark
  • 3
  • 4

1 Answers1

0

There are some suggestions here:

Reading a CSV file in .NET?

Of these, we chose to use Linq2CSV in our MVC projects.

http://www.codeproject.com/KB/linq/LINQtoCSV.aspx

It is fairly easy to use, and validation is nice. You define a simple class that lays out the structure (columns) of the csv file. It will do basic validation, and if that passed, we sent it through a Validator that used DataAnnotation attributes to validate against more complex rules. We found it reliable, and we were able to add some features to it that we wanted.

If the file was pathologically bad, we'd fail the whole thing and present a single error message. If the file was reasonably sound, we would display the rows in error along with the error messages for the row so they could see the problem in context. In our case, this was a display grid only - we did not allow editing through the website - because the CSVs were being generated out of their data system, and we needed them to edit the source data in their system and regenerate the CSV. To do in place editing, you would need to stage all the column values as strings so they can fix numbers that don't parse, etc.

Community
  • 1
  • 1
  • +1 for not allowing the users to edit the data. They should be fixing the source file directly and reimporting - whether that's a generated file or not. – Lee Oades Jul 03 '15 at 14:33