I usually receive the "|" delimated text file from the customer which I have to import it into SQL every week.

what is the best(easiest) way that I can do it from browser.

I need to check into the table first that the record has been change or not if changed then update that record, if not found then insert, if its a same record then skip. Also the text file I received it usually have duplicate records also, so I just need to pick one only.

those records are from 100-500 not more than that.

the following is the code where I went so far.
I am very comfortable to follow any step in order to import that data into SQL.
but this text file reading and importing is dam slow.

<cffile action="" file="#ExpandPath('.')#\Sample.txt" variable="theTextFile">

<cfloop from="1" to="#listlen(theTextFile, chr(10))#" index="i">
    <cfset thisline = listgetat(theTextFile, i, chr(10))>
    <cfset lines[i] = structnew()>
    <cfset lines[i]["GuestID"] = listfirst(thisline, "|")>
    <cfset lines[i]["FName"] = listgetat(thisline, 2, "|")>
    <cfset lines[i]["LName"] = listgetat(thisline, 3, "|")>
    <cfset lines[i]["Address"] = listgetat(thisline, 4, "|")>
    <cfset lines[i]["City"] = listgetat(thisline, 5, "|")>
    <cfset lines[i]["State"] = listgetat(thisline, 6, "|")>
    <cfset lines[i]["ZIP"] = listgetat(thisline, 7, "|")>
    <cfset lines[i]["extra1"] = listgetat(thisline, 8, "|")>
    <cfset lines[i]["extra2"] = listgetat(thisline, 9, "|")>
    <cfset lines[i]["extra3"] = listgetat(thisline, 10, "|")>
     <cfset lines[i]["extra4"] = listgetat(thisline, 11, "|")>
    <cfset lines[i]["extra5"] = listlast(thisline, "|")>
</cfloop>

<cfdump var="#lines#">

regards,

Thanks,
Asim
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to