Yes a regular _expression_ (regex) , what you would want is a regex that
finds any commas that are between quotation marks and either escapes
them or replaces them.


I'm no regex expert and that would take me quite a while to figure out,
maybe later if youre still stuck.


Good luck.

-----Original Message-----
From: ColdFusion Programmer [mailto:[EMAIL PROTECTED]

Sent: 08 October 2003 12:55
To: CF-Talk
Subject: Re:Looping through a list, setting each listItem to a
column


thanks Craig, you've really been of great help. I have another
question for you, what I've noticed is a couple of rows are not
displayed because the document column has a documnet name with a comma
in it. Here is an example.

2003/09/09 14:49:05, "TestUser1",
"/Doc/News/Budgeting,Forecasting & Reporting.doc", "OK"

As you can see the document name
"/Doc/News/Budgeting,Forecasting & Reporting.doc" has a comma in it. And
because our delimeter is "," the list finds 4 items. Can you think of
any way of getting round this problem.

Cheers
Allan
>Had a proper look at it,
>
>you actualy only need 1 loop.
>
><cfset qTmp = QueryNew("DateTime,User,Document,Status")>
><cfloop list="#fOutput#" index="fileLine"
delimiters="#Chr(10)#">
> <cfif listLen(fileLine) eq 4>
>  <cfset tmp = QueryAddRow(qTmp,1)>
>  <cfscript>
>  tmp=QuerySetCell(qTmp,"DateTime", listGetAt(fileLine,1));
>  tmp=QuerySetCell(qTmp,"User", listGetAt(fileLine,2));
>  tmp=QuerySetCell(qTmp,"Document", listGetAt(fileLine,3));
>  tmp=QuerySetCell(qTmp,"Status", listGetAt(fileLine,4));
>  </cfscript>
> </cfif>
></cfloop>
>
>That should ignore any invalid lines too.
>
> -----Original Message-----
> From: ColdFusion Programmer
[mailto:[EMAIL PROTECTED]
>
> Sent: 08 October 2003 11:52
> To: CF-Talk
> Subject: Re:Looping through a list, setting each listItem to a
>column
>
>
> Yes it does work now, thanks a ton for your speedy help.
> Cheers
>
> >This works...
> >
> >
> ><cfset qTmp=QueryNew("DateTime,User,Document,Status")>
> ><cfloop list="#fOutput#" index="lIndex"
delimiters="#Chr(10)#">
> > <cfset tmp=QueryAddRow(qTmp,1)>
> >    <cfloop list="#lIndex#" index="i">
> >  <cfscript>
> >  tmp=QuerySetCell(qTmp,"DateTime", listGetAt(lIndex,1));
> >  tmp=QuerySetCell(qTmp,"User", listGetAt(lIndex,2));
> >  tmp=QuerySetCell(qTmp,"Document", listGetAt(lIndex,3));
> >  tmp=QuerySetCell(qTmp,"Status", listGetAt(lIndex,4));
> >  </cfscript>
> > </cfloop>
> ></cfloop>
> >
> > -----Original Message-----
> > From: ColdFusion Programmer
>[mailto:[EMAIL PROTECTED]
> >
> > Sent: 08 October 2003 11:32
> > To: CF-Talk
> > Subject: Re:Looping through a list, setting each listItem to
a
> >column
> >
> >
> > Craig, I tried running your code and get this error,
> >
> > Invalid list index 2.  
> > In function ListGetAt(list, index [, delimiters]), the value
>of
> >index, 2, is not a valid as the first argument (this list has
1
> >elements). Valid indexes are in the range 1 through the
number
>of
> >elements in the list.  
> >
> > Any ideas?
> >
> > >Try this..
> > >
> > ><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", listGetAt(innerList,1));
> > > tmp=QuerySetCell(qTmp,"User", listGetAt(innerList,2));
> > > tmp=QuerySetCell(qTmp,"Document", listGetAt(innerList,3));
> > > tmp=QuerySetCell(qTmp,"Status", listGetAt(innerList,4));
> > > </cfscript>
> > > <cfset i = i + 1>
> > >   </cfloop>
> > ></cfloop>
> > >
> > >
> > >The listgetat function inside your inner loop is the only
> >change i've
> > >made
> > >
> > > -----Original Message-----
> > > From: Allan Clarke [mailto:[EMAIL PROTECTED]
> > > Sent: 08 October 2003 11:16
> > > To: CF-Talk
> > > Subject: Looping through a list, setting each listItem to
a
> > >column
> > >
> > >
> > > 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",
> > > "/wwwroot/code/article_1.shtml", "OK"
> > > 2003/09/01 11:53:35, "User\testUser2",
> > > "/wwwroot/code/article_2.shtml", "OK"
> > > 2003/09/01 12:04:55, "User\testUser3",
> > > "/wwwroot/code/article_3.shtml", "OK"
> > > 2003/09/01 12:04:58, "User\testUser4",
> > > "/wwwroot/code/article_4.shtml", "OK"
> > > 2003/09/01 12:05:11, "User\testUser5",
> > > "/wwwroot/code/article_5.shtml", "OK"
> > >
> > > Here is the code to read the log file
> > > <cffile
> > > action=""> > > > 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",
> > > "/wwwroot/code/article_1.shtml", "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
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > The New Yahoo! Shopping - with improved product search
> > > http://shopping.yahoo.com
> > >  _____  
> > >
> > >
> >  _____  
> >
> >
>  _____  
>
>
  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to