Today I need to fetch data from *.csv (which has nearly 15,000 records) file and insert such data into our database. At that time, I need to consider how to retrieve data from this file and how to insert into our database. So, I need to consider which method I need to use between "looping in array" and "ListToArray". That's why I've wrote with "looping in array" first.

Here is simple list data including in CSV file.

view plain print about
1007|PPSHEIN|MALE|COLDFUSION DEVELOPER
2008|MIKE|MALE|ANDROID DEVELOPER
3009|RAYMON|MALE|APPLE DEVELOPER

looping in array

view plain print about
1<cfloop index="myindex" list="#mylist#" delimiters="#CHR(10)#">
2    <cfloop index="ind" list="#myindex#" delimiters="|">
3        <cfoutput>- #ind# -<br></cfoutput>
4    </cfloop>
5    <hr>    
6</cfloop>

After rending above coding, it can output correct data but executing time is 16ms.

Ok, no problem. Let's test with "ListToArray".

ListToArray

view plain print about
1<cfloop index="myindex" list="#mylist#" delimiters="#CHR(10)#">
2    <cfset ind = ListToArray(myindex, "|", true, false)>
3    <cfoutput>- #ind[1]# -<br></cfoutput>
4    <cfoutput>- #ind[2]# -<br></cfoutput>
5    <cfoutput>- #ind[3]# -<br></cfoutput>
6    <cfoutput>- #ind[4]# -<br></cfoutput>
7    <hr>    
8</cfloop>

After rending above coding either, it can output correct data but executing time is 15ms.

To compare both coding, 1ms is different for 3 records. To consider 15,000 records, I cannot estimate how much milliseconds will be different.