reading text file issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    reading text file issue

    I have a process that reads a text file then uploads the data into a
    database table. The text file has 10 lines at the end of the file that are
    blank BUT it appears that the enter key or space bar was hit so the code
    thinks its lines of data and this is causing my process to fail. How can I
    skip those lines and have my process continue and complete successfully?
    this file is generated automatically for uploading and then supplied to me
    for the upload process


  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: reading text file issue

    How are you reading the file? StreamReader?

    I use this pattern for line by line type of insert. It can be used to prep a
    bulk load file. NOTE: if you are on SQL Server and set up a bulk load, you
    can set it up to ignore a number of errors.

    string line;

    while(null != (line = reader.ReadLine ()))
    {
    if(line.Trim(). Length != 0)
    {
    ProcessLine(lin e);
    }
    }


    --
    Gregory A. Beamer

    *************** *************** *************** ****
    Think Outside the Box!
    *************** *************** *************** ****
    "John" <whynow@gmail.c om> wrote in message
    news:ek0%23Hrjh GHA.1320@TK2MSF TNGP04.phx.gbl. ..[color=blue]
    >I have a process that reads a text file then uploads the data into a
    >database table. The text file has 10 lines at the end of the file that are
    >blank BUT it appears that the enter key or space bar was hit so the code
    >thinks its lines of data and this is causing my process to fail. How can I
    >skip those lines and have my process continue and complete successfully?
    >this file is generated automatically for uploading and then supplied to me
    >for the upload process
    >[/color]


    Comment

    Working...