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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to import info from a CSV

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hi

I would like to do a match on IP addresses in a returned recordset but would like to have a separate file with all the different records to be matched (not using the db)

If string_IPaddress = "list of IPs in a file" then...

How can I do this?

Thanks
 
You will need to open the text file using FSO and read line by line:

Code:
set fso = Server.Createobject("Scripting.FileSystemObject")
    path = "c:\temp\ipAddress.txt"
    set file = fso.opentextfile(path, 1)

	
    do until file.AtEndOfStream
		If string_IPaddress = file.ReadLine then
            Response.write("<br> string_IPaddress = " & string_IPaddress & "<br>")
		end if
    loop

    file.close
    set file = nothing
    set fso = nothing
 
Thanks kendal, I'll try that in work tomorrow!
 
Ah, I forgot, it's a CSV file. You will have to read the whole file and split it out to an array, then loop through this array.

Code:
arrayIP = Split( file.ReadAll, ", " )

for i = LBound(arrayIP) to UBound(arrayIP)
	If string_IPaddress = trim(arrayIP(i)) then
            Response.write("<br> string_IPaddress = " & trim(arrayIP(i)) & "<br>")
	end if
next
 
use a ADO file connection? and access the CSV as a recordsource


see the FAQ section.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top