3 Replies Latest reply on Jun 26, 2008 7:41 AM by spacehog

    Removing carriage returns

    spacehog Level 1
      I am trying to import an 8 column .csv file into my database unfortunately column 7 has a carriage return at the end which causes CF to throw the error, "Incorrect number of columns".

      How do I get rid of the carriage returns during import?
        • 1. Re: Removing carriage returns
          dempster Level 1
          I assume that by using the "name" parameter you're trying to process the file as a query. That is why you're getting the error. You might be better off trying to process it as a block of text.

          Get rid of the name and the contents of the file will be in the variable CFHTTP.FileContent . You'll have to develop a function to loop through the file and parse the contents. If every record has a CR in column 7, for example, you could extract each record by looking for each second CR. Then you treat it as a comma-delimted list.
          • 2. Re: Removing carriage returns
            BKBK Adobe Community Professional & MVP
            My first attempt to filter out the carriage return would be something like

            <cfset prematureEndOfRow = chr(13)&",">
            <cfset content = replace(content, prematureEndOfRow, "," ,"all")>

            • 3. Re: Removing carriage returns
              spacehog Level 1
              Dempster, thanks. It struck me as I read your answer. It is an extra step, but I am importing the file as text, removing the carriage returns, and then pushing it back into a query object using QueryNew()