CFhttp - Using delimiter when reading a CSV file in ColdFusion

cfhttp - delimiter attribute

employee.csv


Emp_ID; FirstName; LastName
1; Jenny; Jones
2; Anne; Patel
3; Sonia; Akter


cfhttpDelimiter.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfhttp: how to use delimiter attribute when read a csv file in coldfusion</title>
</head>

<body>
<h2 style="color:DeepPink; font-style:italic">cfhttp tag example: how to use delimiter attribute</h2>
<hr width="500" align="left" color="OrangeRed" />
<br />

<cfhttp 
 method="get"
    url="http://localhost:8500/cfexample/employee.csv" 
    name="EmployeeData"
    delimiter=";"
    >
</cfhttp>

<table border="1" cellpadding="5" cellspacing="0" bordercolor="Crimson">
    <tr bgcolor="OrangeRed" style="color:Snow; font-weight:bold">
        <td>
            Employee ID
        </td>
        <td>
            First Name
        </td>
        <td>
            Last Name
        </td>
    </tr>
 <cfoutput query="EmployeeData">
     <tr bgcolor="Snow" style="color:Crimson; font-weight:normal">
         <td>
                #Emp_ID#
            </td>
         <td>
                #FirstName#
            </td>
         <td>
                #LastName#
            </td>
        </tr>
    </cfoutput>
</table>

</body>
</html>





More ColdFusion examples