Skip to main content
Participating Frequently
February 5, 2010
Answered

trimming data and splitting into columns for csv

  • February 5, 2010
  • 2 replies
  • 452 views

Hi,

I am pretty new to CF but usually work with php. I am helping out with a site to create a csv export of records. I am able to export csv no problem. This file is provided to a third party that requested this format.

I need to take a field that contains this data :

EDUDIRECT or

EDUINDIRECT

and others

and strip the first three chars and place it in one column and take the rest and place it in another column. Is there a CF function or command that will allow me to do this?

We will always pull the first 3 off and the remainder goes elsewhere.

Col1     Col2

EDU     DIRECT

Thanks for your help.

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    Most databases have string functions like left(), right() and substring(). (The extact syntax is database dependent obviously). So you could either split the values within your database query or use CF's string functions. With CF you could use a combination of these functions:

    LEFT() to grab the first 3 characters

    RIGHT() and LEN() to grab the remaining ones (Or possibly the MID function as well)

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6a3a.html

    Message was edited by: -==cfSearching==-

    2 replies

    cbrimmanAuthor
    Participating Frequently
    February 5, 2010

    Thanks guys that was fast and very helpful I used left and it was successful. Remove chars should come in handy as well!

    -__cfSearching__-Correct answer
    Inspiring
    February 5, 2010

    Most databases have string functions like left(), right() and substring(). (The extact syntax is database dependent obviously). So you could either split the values within your database query or use CF's string functions. With CF you could use a combination of these functions:

    LEFT() to grab the first 3 characters

    RIGHT() and LEN() to grab the remaining ones (Or possibly the MID function as well)

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6a3a.html

    Message was edited by: -==cfSearching==-

    Inspiring
    February 5, 2010

    Another function that will get characters except the 3 on the left is RemoveChars().