473,419 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

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
Jun 2 '06 #1
1 1547
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(line);
}
}
--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"John" <wh****@gmail.com> wrote in message
news:ek****************@TK2MSFTNGP04.phx.gbl...
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

Jun 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dunnm | last post by:
This is probably a more appropriate location to post this question. I should have know that since I've found most of the other PHP/PDF information contained in this group. Here's my issue...I...
2
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
14
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
3
by: Roland Hall | last post by:
Three times the charm? Sorry for the repost. Trying to get my account right. I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already...
4
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to...
10
by: T Cordon | last post by:
I am using a StreamReader to read text from an HTML file and display it as part of a page in a Label Control. Buy it is not displaying characters as: ñ, ó, ú, etc. Please Help. Thanks
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
1
by: bbepristis | last post by:
Hey all I have a wired issue I have a csv file with , seperated values I have some code to read the file and put the record into an array then into textboxes. the problem is it seems to read...
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
3
by: aaljumah | last post by:
i am naive with java programming. I would like create a program to read a set of text files, analyze them and create an output in an xml format or at least to another one txt file. here is how...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.