Whatever message this page gives is out now! Go check it out!

CSVProcess

Last update:
May 18, 2026

Description

CSVProcess reads an input csv by reading each line, filters the rows based on a condition, modifies the values, and writes the value. The function is applicable to only arrayofjavaarray and arrayofCFarray output formats.

Returns

None

History

  • ColdFusion (2025 release): Added the function.

Syntax

CSVProcess(filePath,rowProcessor,rowFilter[,csvFormatConfiguration])

Parameters

Name
Required
Type
Description
filePath
Yes
String
The path of the CSV file to be read.
rowProcessor
Yes
UDF
Method to run for each row. This method accepts two parameters – row and row number. It needs to return CSV object.
rowFilter
Yes
UDF
Method to filter each row based on a condition.
processRowAsJavaArray
No
Boolean
Whether to process row as Java array (for better performance). Valid only for arrayof JavaArray.
csvFormatConfiguration
No
Struct
A struct containing the configuration of reading the streaming spreadsheet. The keys are:
Property
ArrayofCFArray
ArrayofJavaArray
delimiter
Yes
Yes
encoding
Yes
Yes
escapeCharacter
Yes
Yes
ignoreEmptyLines
Yes
Yes
nullString
Yes
Yes
quoteCharacter
Yes
Yes
trailingDelimiter
Yes
Yes

Example 1

<cfscript> 
    valuesProcessed = 0; 
    cashPayment = 0; 
    theFile = GetDirectoryFromPath(GetCurrentTemplatePath()) & "CSVReadFile.csv"; 
    CSVProcess(filepath =#theFile#,rowprocessor =(row, rowNumber)=> { 
        valuesProcessed += ArrayLen(row) 
        index = arrayfind(row, "2021") 
        if(index neq -1) cashPayment++; 
    }, 
    rowFilter = (row, rowNumber)=> { 
        //return true 
        if(rowNumber mod 2 eq 0) return true 
        else return false 
    },csvformatconfiguration={}) 
    writeoutput('Entries processed : ' & valuesProcessed & '<br>Cash paid for ' & cashPayment & ' trips.') 
</cfscript>

Example 2

Using delimiter in the struct
<cfscript> 
    valuesProcessed = 0; 
    cashPayment = 0; 
    theFile = GetDirectoryFromPath(GetCurrentTemplatePath()) & "CSVReadFile.csv"; 
    CSVProcess(filepath =#theFile#,rowprocessor =(row, rowNumber)=> { 
        valuesProcessed += ArrayLen(row) 
        index = arrayfind(row, "2021") 
        if(index neq -1) cashPayment++; 
    }, 

    rowFilter = (row, rowNumber)=> { 
        //return true 
        if(rowNumber mod 2 eq 0) return true 
        else return false 
    },csvformatconfiguration={"delimiter":","}) 
    writeoutput('Entries processed : ' & valuesProcessed & '<br>Cash paid for ' & cashPayment & ' trips.') 
</cfscript>

Example 3

Using nullstring in the struct
<cfscript> 
    valuesProcessed = 0; 
    cashPayment = 0; 
    theFile = GetDirectoryFromPath(GetCurrentTemplatePath()) & "CSVReadFile.csv"; 
    CSVProcess(filepath =#theFile#,rowprocessor =(row, rowNumber)=> { 
        valuesProcessed += ArrayLen(row) 
        index = arrayfind(row, "2021") 
        if(index neq -1) cashPayment++; 
    }, 
    rowFilter = (row, rowNumber)=> { 
        //return true 
        if(rowNumber mod 2 eq 0) return true 
        else return false 
    },csvformatconfiguration={"nullString":"2021"}) 
    writeoutput('Entries processed : ' & valuesProcessed & '<br>Cash paid for ' & cashPayment & ' trips.') 
</cfscript>

Example 3

Using csvformatconfiguration={"quoteMode":"ALL","quotecharacter":"'"}
<cfscript> 
    valuesProcessed = 0; 
    cashPayment = 0; 
    theFile = GetDirectoryFromPath(GetCurrentTemplatePath()) & "CSVReadFile.csv"; 
    CSVProcess(filepath =#theFile#,rowprocessor =(row, rowNumber)=> { 
        valuesProcessed += ArrayLen(row) 
        index = arrayfind(row, "2021") 
        if(index neq -1) cashPayment++; 
    }, 

    rowFilter = (row, rowNumber)=> { 
        //return true 
        if(rowNumber mod 2 eq 0) return true 
        else return false 

    },csvformatconfiguration={"quoteMode":"ALL","quotecharacter":"'"}) 
    writeoutput('Entries processed : ' & valuesProcessed & '<br>Cash paid for ' & cashPayment & ' trips.') 
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page