reading text file

J

John

How can I tell if a line begins with a number instead of a character? I need
to read a text file and some of the data begins with a character which is
causing me an issue in reading and uploading my file. I only need the data
if it begins with a number (numeric) value.
 
L

Laurent Bugnion

Hi,
How can I tell if a line begins with a number instead of a character? I need
to read a text file and some of the data begins with a character which is
causing me an issue in reading and uploading my file. I only need the data
if it begins with a number (numeric) value.

If I understand you correctly, you want to read the file on the client
*before* it is uploaded on the server?

JavaScript is not allowed to read local files without special
permissions (which the user might or might not grant), so even if you
decide to implement a client-side solution, you must check the data on
the server, and simply ignore it (with an appropriate error message) if
it doesn't fit your expectations. When you receive the file, you can
inspect the content from the memory stream before saving it.

HTH,
Laurent
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

John said:
How can I tell if a line begins with a number instead of a character? I need
to read a text file and some of the data begins with a character which is
causing me an issue in reading and uploading my file. I only need the data
if it begins with a number (numeric) value.

You can use the Char.IsDigit method to check if the first character is a
digit.

If you need something more complex, you could use a regular expression
to validate the data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top