Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP NET Parser FileUpload
Hi,
 
One of my requirement is that a user can upload with various file like CSV, excel, Fixed file format, XML etc.
 
Can i have any common parser which can parse any file in the given list and convert it into dataset or datatable for DB insertion.
 
Also in future if any new file format comes which is not in the list, it should be very easy to attach a logic with that file format.
 
i am working on asp.net and .net 3.5 and MSSQL2008.
Posted 20-Jan-13 23:58pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No.
There is no such thing as a "parser for any file format", and though it would be possible to create a class that could be expanded to parse new formats, there are so many different formats (just the number of different file formats Microsoft have used over the years is staggering) that it is impractical to try and create a single parser to do all jobs.
 
Think of what files you need to support, and look at finding existing parsers for each of them. (They will all work in radically different ways, so getting them to work "nicely" together is going to be a fair amount of work anyway)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

For the formats you listed, you might try OLEDB[^].
The "etc." and the "fixed format" on the file format list distroys the above mentioned approach, though.
Cheers
Andi
  Permalink  
Comments
Pinank_CD at 22-Jan-13 3:23am
   
Hi Andreas,
 
you are corret on your part, but in the market there are 3rd party parser available, even they must be using some logic build the data out of a stream. dont know but there should be some solution to other formats as well after all everything is bit of piece. :)
Andreas Gieriet at 22-Jan-13 4:11am
   
I don't know what your understanding of a parser is. I mean, you can always implement a kind of "chain of commands" gerneral purpose parser that consists of a lot of parser plugins. Each plugin must decide if it can parse the piece of data (and doit if possible, or say "no" and let the chain-of-command hand over to the next).
The challenge for such a plugin are
1) how to easily detect if it can parse (either some header magic (e.g. sh-bang), or some brute-force attempt to parse and if error, say "no").
2) get the spec for the format (e.g. you hardly get a spec for Excel format)
3) parse the whole universe of a given spec (e.g. Excel again: strip away all the rendering, graphics, font, etc. data and extract only the data - what about formulas: evaluate or as formula? etc.)
 
You do not want to invent all that.
Search the net an download/buy ready to use solutions.
 
Building that yourself will cost you more money/time than you probably have/are willing to spend.
 
Andi
Pinank_CD at 22-Jan-13 4:21am
   
i think what you are saying is logically correct. there can be lots of formats and each one of them can have different methods to access. Same comments were posted by OriginalGriff. thank you all of you. marking this as a solution.
Andreas Gieriet at 22-Jan-13 4:34am
   
Thanks for accepting this as a "solution", even I could not really "solve" your primary request.
Cheers
Andi
PS: To reply to a comment, click on the top right of the comment - there is a "reply" link.
Pinank_CD at 22-Jan-13 4:39am
   
Hey Andi,
 
i will be eager to share my solution, in case if succeed with some new solution. how can i reach you?
Andreas Gieriet at 22-Jan-13 5:55am
   
See my profile and follow the links.
Cheers
Andi
Pinank_CD at 22-Jan-13 6:12am
   
cant see your email, where should i send?
Andreas Gieriet at 22-Jan-13 8:10am
   
Maybe it's best to post any news here in CP as tip or if it's more elaborate, as an article. This was then for the benenfit of everyone.
Cheers
Andi
PS: My email addreass is under my web page --> firma --> team --> my name --> ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,130
1 DamithSL 5,089
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,647
4 Kornfeld Eliyahu Peter 4,409


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100