On Fri, 12 Mar 2004 08:30:55 -0500, "Rahul Chatterjee"
<ra***@benesysinc.com> wrote:
I am uploading a file using ASP code. After the user uploads the file, I
would like to be able to open the file and check if the data is in a given
format (comma separated) and also has all the data elements needed (i.e. all
fields are there). Is there a parse routine in asp that would allow me to do
this. The user can upload any type of file as long as I am able to parse it
and determine if the data is of the aforemention type.
Parsing is somthing you have to code yourself, though there are
obviously a number of functions you can use, such as Split, InStr,
StrComp, etc. Counting comma separated fields could be easy, do a
ReadLine and then a Split at commas and count the elements. You might
even ask the uploader to specify the delimiter from a list, and do the
Split on that delimiter.
If you decide to accept *any* type of input your job gets harder.
Stripping HTML codes, escaping various characters, Trimming spaces and
the like could run hundreds of lines of code, and accepting non-text
files such as an Excel file would further complicate things. You'd
likely have to find a component to do file conversions as part of the
process.
Controlling what the user can supply makes it easier to work with what
you receive.
Jeff