Hi All,
I have been using CFFILE to loop through a CSV file. The problem I am having is that if the value of the cell (as if displayed in a spreadsheet) is blank, then an error is thrown... What I want to be able to do is to replace any NULL sting value with non-breaking space or ignore them completely and move on.
I have attached some code with what I want to do, but I am struggling to implement it.
<cffile action="read" file="#expandpath(cffile.ServerFile)#" variable="fileData">
<table border="1" bordercolor="#F8F8F8" cellpadding="2" cellspacing="0">
<tr bgcolor="#3366FF">
<td><strong>SUBSCRIBER NO.</strong></td>
<td><strong>ORDER NO.</strong></td>
<td><strong>CLIENT NAME</strong></td>
<td><strong>CIRCUIT NO.</strong></td>
<td><strong>BEARER</strong></td>
<td><strong>RWS HOST NAME</strong></td>
</tr>
<cfset R = 0>
<cfloop index="record" list="#fileData#" delimiters="#chr(10)##chr(13)#">
<tr<cfif R EQ 0> bgcolor="#CCCCCC"<cfelse> bgcolor="#FFFFFF"</cfif>>
<td><cfif listgetat(record,1,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,1,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,2,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,2,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,3,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,3,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,4,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,4,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,5,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,5,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,6,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,6,chr(44))#</cfoutput></cfif></td>
</tr>
<cfif R EQ 0>
<cfset R = 1>
<cfelseif R EQ 1>
<cfset R = 0>
</cfif>
</cfloop>
</table>
I have been using CFFILE to loop through a CSV file. The problem I am having is that if the value of the cell (as if displayed in a spreadsheet) is blank, then an error is thrown... What I want to be able to do is to replace any NULL sting value with non-breaking space or ignore them completely and move on.
I have attached some code with what I want to do, but I am struggling to implement it.
<cffile action="read" file="#expandpath(cffile.ServerFile)#" variable="fileData">
<table border="1" bordercolor="#F8F8F8" cellpadding="2" cellspacing="0">
<tr bgcolor="#3366FF">
<td><strong>SUBSCRIBER NO.</strong></td>
<td><strong>ORDER NO.</strong></td>
<td><strong>CLIENT NAME</strong></td>
<td><strong>CIRCUIT NO.</strong></td>
<td><strong>BEARER</strong></td>
<td><strong>RWS HOST NAME</strong></td>
</tr>
<cfset R = 0>
<cfloop index="record" list="#fileData#" delimiters="#chr(10)##chr(13)#">
<tr<cfif R EQ 0> bgcolor="#CCCCCC"<cfelse> bgcolor="#FFFFFF"</cfif>>
<td><cfif listgetat(record,1,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,1,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,2,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,2,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,3,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,3,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,4,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,4,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,5,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,5,chr(44))#</cfoutput></cfif></td>
<td><cfif listgetat(record,6,chr(44)) EQ ''> <cfelse><cfoutput>#listgetat(record,6,chr(44))#</cfoutput></cfif></td>
</tr>
<cfif R EQ 0>
<cfset R = 1>
<cfelseif R EQ 1>
<cfset R = 0>
</cfif>
</cfloop>
</table>