Read start of CSV file with JS/jQuery

Associate
Joined
3 Jan 2006
Posts
522
Location
The Undercroft
I'm currently looking into the possibilities of a web based data import app and slightly stuck at the first hurdle.
Say the client has a CSV text file with some 5000+ records to be imported to a DB on the server, can I use javascript/jQuery to read only the first few lines to verify it is indeed a CSV file and get the structure of the data before uploading the entire file to the server?
I've been googling it and not found anything helpful, is JS capable of this?
How do you do partial file uploads?
It will be a C#.net MVC app. No flash!
Any help appreciated.

Edit: I realise a 5000 line txt file isnt that big and can be uploaded straight off and be processed server side but theres the potential for files containing 50k+ records over a slow wireless connection.
 
Last edited:
Yeah thats what I suspected. I guess we can just upload the smaller files and deal with the odd larger file another way.
 
Nice idea JIMA but there isnt a fixed layout for the source file - it could have any number of fields and will be mapped to the destination table by the user.
I'll just do all file validating/processing server-side, less of a headache
 
Back
Top Bottom