Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading null a record from a text file

Status
Not open for further replies.

week

MIS
Feb 14, 2001
118
US
I have a text file I am trying to upload into a table. I am doing that by reading one line at a time from a text file. Sometimes the text file has blank spaces (it appears to be) at the end of the file. When it encounters, the process errors out. How can I say to skip the line if it is blank?

I tried
if d.item(&quot;IMPORT_REC&quot;) & &quot;&quot; <> &quot;&quot; then
if d.item(&quot;IMPORT_REC&quot;) <> &quot;&quot; then
if IsNull(d.Item(&quot;IMPORT_REC&quot;)) then

But none of them seem to work.

Thanks for any tips.
 
how about:

if TRIM(d.item(&quot;IMPORT_REC&quot;)) <> &quot;&quot; then
'do your error processing here, or skip the rec.....
 
I tried what lobstah suggested but it didn't work.

I think have mispresented the problem. I don't know what really those blanks are. It's some character that Windows doesn't support. So it appears to be blank spaces. arrLine(0) is the actual record I am working on. d.item(&quot;import_rec&quot;) is derived from arrLine(0). When I do
Response.Write(Asc(arrLine(0))), it gives me 53535353535353...

But when I tried:
strangeChar = Asc(arrLine(0))
if instr(InspectString(trim(arrLine(0))), strangeChar) < 0
then

it still didn't work.

Any other thoughts?
 
what do you get if you do:

response.write (arrLine(0))

does it just give a blank line?
 
Yup, blank lines... but when I check it for null, it thinks it has something in it.
 
I came up with some kind of solution. I found out all my lines has a common char per record by doing response.write asc(arrLine(0)). It gave me 53. So, I have a logic in my script like this:

if instr(trim(asc(arrLine(0))), 53) > 0 then
insert to table
else
do nothing
end if

This works now...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top