2010年9月10日 星期五

讀csv檔並做(中文)筆劃排序

<cffile action = "read" file = "#expandpath('csv.csv')#" variable = "csv_show" >
<cfset myQuery = QueryNew("name,main, joblist, bloglink ,sowf")><!----定義新的Query---->
<cfset newRow = QueryAddRow(myQuery,ListLen(csv_show,chr(13)&chr(10)))> <!----給新的Query預設Row大小----->
<cfloop index="N" from="2" to="#ListLen(csv_show,chr(13)&chr(10))#" >
     <cfset "list#N#" = ListGetAt(csv_show,#N#,chr(13)&chr(10)) >
     <cfset temp = QuerySetCell(myQuery, "name", #ListGetAt(#evaluate("list#N#")#,1)#,N)>
     <cfset temp = QuerySetCell(myQuery, "main", #ListGetAt(#evaluate("list#N#")#,2)#, N)>
     <cfset temp = QuerySetCell(myQuery, "joblist", #ListGetAt(#evaluate("list#N#")#,3)#, N)>
     <cfset temp = QuerySetCell(myQuery, "bloglink", #ListGetAt(#evaluate("list#N#")#,4)#, N)>
     <cfset temp = QuerySetCell(myQuery, "sowf", tobase64(ListGetAt(evaluate("list#N#"),3),"big5"), N)>
</cfloop>
<cfquery name="JobList" dbtype="query">
     SELECT name,main, joblist, bloglink ,sowf
       FROM myQuery
     order by sowf  
</cfquery>
<cfoutput query="JobList">
      #joblist#  #sowf#  <br>
</cfoutput>

沒有留言:

張貼留言