ColdFusionKing
Programmer
Hello Everybody,
I am trying to read a log file and display the results on a webpage.
Here is what the log file looks.
DateTime User Webpage Visited Status
2003/09/01 11:52:15, "User\testUser1", "/ "OK"
2003/09/01 11:53:35, "User\testUser2", "/ "OK"
2003/09/01 12:04:55, "User\testUser3", "/ "OK"
2003/09/01 12:04:58, "User\testUser4", "/ "OK"
2003/09/01 12:05:11, "User\testUser5", "/ "OK"
Here is the code to read the log file
<cffile
action="read"
file="C:\myLogFile.log"
variable="fOutput">
Take a look at the code below. As you can see I am looping through the list, finding the Carriage Return character.
This is all fine, what I want to be able to do is loop through each individual row which is again a comma seprated list
(2003/09/01 11:52:15, "User\testUser1", "/ "OK"
append each list item in a temp table column.
<cfset qTmp=QueryNew("DateTime,User,Document,Status"
>
<cfloop list="#fOutput#" index="lIndex" delimiters="#Chr(10)#">
<cfset i = 0>
<cfset tmpstart=listLen(lIndex,',')>
<cfset tmp=QueryAddRow(qTmp,listLen(lIndex,','))>
<cfloop list="#lIndex#" index="innerList" delimiters=",">
<cfscript>
tmp=QuerySetCell(qTmp,"DateTime", innerList);
tmp=QuerySetCell(qTmp,"User", innerList);
tmp=QuerySetCell(qTmp,"Document", innerList);
tmp=QuerySetCell(qTmp,"Status", innerList);
</cfscript>
<cfset i = i + 1>
</cfloop>
</cfloop>
<cfquery name="lquery" dbtype="query">
SELECT DISTINCT *
FROM qTmp
</cfquery>
The code above is not right, and I've tried hard to figure out how to loop through the inner comma separated list and assign the value to the query column. Can somebody
please show me how to do this. I know my explaination is not very clear but I hope you know what I'm trying to do.
If you think there is an easier way to do this then please let me know. Please can somebody help
Regards
John
I am trying to read a log file and display the results on a webpage.
Here is what the log file looks.
DateTime User Webpage Visited Status
2003/09/01 11:52:15, "User\testUser1", "/ "OK"
2003/09/01 11:53:35, "User\testUser2", "/ "OK"
2003/09/01 12:04:55, "User\testUser3", "/ "OK"
2003/09/01 12:04:58, "User\testUser4", "/ "OK"
2003/09/01 12:05:11, "User\testUser5", "/ "OK"
Here is the code to read the log file
<cffile
action="read"
file="C:\myLogFile.log"
variable="fOutput">
Take a look at the code below. As you can see I am looping through the list, finding the Carriage Return character.
This is all fine, what I want to be able to do is loop through each individual row which is again a comma seprated list
(2003/09/01 11:52:15, "User\testUser1", "/ "OK"
<cfset qTmp=QueryNew("DateTime,User,Document,Status"
<cfloop list="#fOutput#" index="lIndex" delimiters="#Chr(10)#">
<cfset i = 0>
<cfset tmpstart=listLen(lIndex,',')>
<cfset tmp=QueryAddRow(qTmp,listLen(lIndex,','))>
<cfloop list="#lIndex#" index="innerList" delimiters=",">
<cfscript>
tmp=QuerySetCell(qTmp,"DateTime", innerList);
tmp=QuerySetCell(qTmp,"User", innerList);
tmp=QuerySetCell(qTmp,"Document", innerList);
tmp=QuerySetCell(qTmp,"Status", innerList);
</cfscript>
<cfset i = i + 1>
</cfloop>
</cfloop>
<cfquery name="lquery" dbtype="query">
SELECT DISTINCT *
FROM qTmp
</cfquery>
The code above is not right, and I've tried hard to figure out how to loop through the inner comma separated list and assign the value to the query column. Can somebody
please show me how to do this. I know my explaination is not very clear but I hope you know what I'm trying to do.
If you think there is an easier way to do this then please let me know. Please can somebody help
Regards
John