This works,


it's a bit of a fudge, but it does the job.


<cfset qTmp = QueryNew("DateTime,User,Document,Status")>
<cfloop list="#fOutput#" index="fileLine" delimiters="#Chr(10)#">
<cfif listLen(fileLine) gte 4>
  <cfset tmp = QueryAddRow(qTmp,1)>
  <cfif listLen(fileLine) gt 4>
   <cfscript>
   QuerySetCell(qTmp,"DateTime", listGetAt(fileLine,1));
   QuerySetCell(qTmp,"User", listGetAt(fileLine,2));
   QuerySetCell(qTmp,"Status", listlast(fileLine));
   
   x = listLen(fileLine) - 1;
   doc = "";
   for ( i = 3 ; i lte x ; i = i + 1 ){
    doc = doc & "," & listGetAt(fileLine,i);
   }
   
   QuerySetCell(qTmp,"Document", doc);
   </cfscript>   
  <cfelse>
   <cfscript>
   QuerySetCell(qTmp,"DateTime", listGetAt(fileLine,1));
   QuerySetCell(qTmp,"User", listGetAt(fileLine,2));
   QuerySetCell(qTmp,"Document", listGetAt(fileLine,3));
   QuerySetCell(qTmp,"Status", listGetAt(fileLine,4));
   </cfscript>  
  </cfif>
</cfif>
</cfloop>

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

Sent: 09 October 2003 10:43
To: CF-Talk
Subject: Re:Looping through a list, setting each listItem to a
column


I'm afraid it does not work. I replaced my script with yours and
it did'nt work. There is one column which contains commas in it, I want
to escape the comma, I have made an effort, but I can't get my head
round it which is why I'm asking for other people's help. Here is an
example

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

As you can see the string "/Doc/News/Budgeting,Forecasting &
Reporting.doc" has a comma in it, I want to escape it.

Thanks for your help

>The script wasn't meant to give you a regexp to replace the
commas. It
>does the entire job of creating the query and takes the " as a
>qualifier into consideration. Replace your script by mine and
it
>should work.
>
> -----Oorspronkelijk bericht-----
> Van: ColdFusion Programmer
[mailto:[EMAIL PROTECTED]
> Verzonden: wo 8/10/2003 17:32
> Aan: CF-Talk
> CC:
> Onderwerp: Re:Looping through a list, setting each listItem to
a
>column
>
>
> I've tried that and it does not work. Here is my code
>
> <cfscript>
> myList = '2003/09/09 14:49:05, "TestUser1",
"/Doc/News/Budgeting,
>Forecasting & Reporting.doc", "OK"';
> myList = REReplace(myList, '^[[:space:]]*([^,
>]*|"([^"]|"")*")[[:space:]]*(,|$)','');
> </cfscript>
> <cfoutput>#myList#</cfoutput>
>
> >This should do it in CF using regexp.
> >There are probably custom tags that will read logs more
efficiently
>
> >though.
>
>
  _____  


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

Reply via email to