DATETIME DOCUMENT STATUS USER
1 09-Oct-03 test2" [empty string] "test"
2 2003/09/09 14:49:05 "/Doc/News/Budgeting Forecasting & Reporting.doc" "TestUser1"
>The script works for me. I am not escaping anything, just extracting the
>correct info from the csv (log). See code below. The only thing I
>changed is to take blank lines into consideration (it hanged my cf if
>there was a blank line at the end). Also: as I said before, there are
>custom tags that will read csv's more efficiently
>
><cfoutput><cfsavecontent variable="fOutput">Date User Webpage Status
>#DateFormat(Now())#, "test", "test2"
>2003/09/09 14:49:05, "TestUser1", "/Doc/News/Budgeting,Forecasting &
>Reporting.doc", "OK"
></cfsavecontent>
><cfscript>
>columns = "DateTime,User,Document,Status";
>qTmp = QueryNew(columns);
>pattern = '^[[:space:]]*([^,]*|"([^"]|"")*")[[:space:]]*(,|$)';
>matchStruct = structNew();
>for(i=2;i LE ListLen(fOutput,chr(10));i=i+1){
> line = ListGetAt(fOutput,i,chr(10));
> if(Len(line)){
> QueryAddRow(qTmp,1);
> exit = false;
> j = 1;
> while(NOT exit){
> // find matching pattern
> matchStruct = REFindNoCase(pattern,line,1,true);
> if(matchStruct.pos[1] AND j LE ListLen(columns)){
> field = Mid(line,matchStruct.pos[2],matchStruct.len[2]);
> WriteOutput("#i#.#j#:|#field#|");
> QuerySetCell(qTmp,ListGetAt(columns,j),field);
> if(matchStruct.len[1])
> line = RemoveChars(line,1,matchStruct.len[1]);
> j = j + 1;
> }
> else exit = true;
> }
> }
>}
></cfscript>
><h1>Log</h1>
><pre>
>#fOutput#
></pre>
><cfdump var="#qTmp#">
></cfoutput>
>
>Pascal Peters
>Certified ColdFusion MX Advanced Developer
>Macromedia Certified Instructor
>LR Technologies
>Av. E. De Mot, 19
>1000 BRUSSELS, BELGIUM
>Tel: +32 2 639 68 70
>Fax: +32 2 639 68 99
>Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>Web: www.lrt.be
>
>-----Original Message-----
>From: ColdFusion Programmer [mailto:[EMAIL PROTECTED]
>Sent: donderdag 9 oktober 2003 11: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.
>>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

