我有一个制表符分隔的文本文件,其中包含可怕的“NULL”值。经过一番搜索,我发现如何用“某物”替换空字符串……。但是当我这样做时,我似乎失去了一半的价值观。
<cfset thisRow = replace(thisRow, "#chr(9)##chr(9)#", "#chr(9)#ScoobySnack#chr(9)#", "all")>
例如:一行数据包含 120 个“空选项卡” - 但是当我执行此解决方法时 - 我只返回 60。片段在这里:
<cffile action="read" file="c:\websites\the website\UsageData\#MyFile.NAME#" variable="myDataFile">
<cfset rowCount = listLen(myDataFile,chr(13))>
-Other stuff happens-
<cfloop from="1" to="#rowCount#" index="i">
<table cellpadding="2" cellspacing="0" border="1">
<tr>
<th>ID</th>
<th>Date</th>
<th>Time</th>
<th>DeviceMac</th>
<th>DeviceAddress</th>
<th>DeviceName</th>
<th>UsageBytes</th>
</tr>
<!--- set current row to simple variable --->
<cfset thisRow = listGetAt(myDataFile,i,chr(13))>
<cfset Field1 = listGetAt(thisRow,1,chr(9))>
<cfset Field2 = listGetAt(thisRow,2,chr(9))>
<cfset Field3 = listGetAt(thisRow,3,chr(9))>
<cfset thisRow = replace(thisRow, "#chr(9)##chr(9)#", "#chr(9)#ScoobySnack#chr(9)#", "all")>
<cfset variables.CheckColumnCount = listLen(thisRow,chr(9))>
<cfif variables.CheckColumnCount NEQ variables.ColumnCount>
<cfset variables.AdjustedColumnCount = (variables.CheckColumnCount - 3)>
<cfelse>
<cfset variables.AdjustedColumnCount = (variables.ColumnCount - 3)>
</cfif>
<!---Row #i# Data as a string (#thisRow#)<br/>--->
<cfset ColNum = 4>
<!--- now loop the row --->
<cfloop from="1" to="#variables.AdjustedColumnCount#" index="r">
<cfif r EQ 1>
<cfset variables.MyLoopStartTime = variables.MyStartTime>
<cfelse>
</cfif>
<tr>
<td>#ColNum#</td>
<td>#variables.thisDate#</td>
<td>#TimeFormat(variables.MyLoopStartTime,"hh:mm:ss")#</td>
<td>#Field1#</td>
<td>#Field2#</td>
<td>#Field3#</td>
<td>#listGetAt(thisRow,ColNum,chr(9))#</td>
</tr>
<cfset variables.MyLoopStartTime = DateAdd('n', 1, variables.MyLoopStartTime)>
<cfset ColNum = ColNum +1>
</cfloop>
</table>
<hr>
<cfset count = count + 1>
</cfloop>
想法?