6 Replies Latest reply on Jan 11, 2016 11:19 AM by Alan Koenig_920

    getlistat error

    Alan Koenig_920

      my code:

       

      <cffile action="read" file="http://website.com/test1.txt" variable="data"  attributes="readonly" >

       

      <cfoutput >

      #data#

      </cfoutput>

       

      <cfloop index="i" list="#data#" delimiters= "#chr(9)#" >

      <cfquery datasource="X" username="Y" password="Z" timeout="90">

      INSERT INTO property

         (

         PublicRemarks,

         MLSID)

      VALUES

           (

          '#replace(listGetAt(i,1),'"','','all')#',

          '#replace(listGetAt(i,2),'"','','all')#'

         

          )

      </cfquery>

      </cfloop>

       

      My Error:

      Invalid list index 2.

      In function ListGetAt(list, index [, delimiters]), the value of index, 2, is not a valid as the first argument (this list has 1 elements). Valid indexes are in the range 1 through the number of elements in the list.
      The error occurred in D:/home/manpcs.com/wwwroot/Untitled_cfm.cfm: line 19
      17 :      ( 18 :     '#replace(listGetAt(i,1),'"','','all')#', 19 : '#replace(listGetAt(i,2),'"','','all')#' 20 : 21 :     ) 

       

      My Question:

      This is a tab delimited txt file.  I am attempting to break the data up so that I can store it in my database.   The data is being read as I can see from the output however I am unable to properly separate the data for my database.  How do I properly seperate the data so that it will go into my database?

      Thank you in advance for any and all help.

        • 1. Re: getlistat error
          WolfShade Level 4

          Without being able to see the format of the contents of test.txt, it's difficult to speculate.

           

          But the error you reference indicates that either A) there is no tab in the data (it _could_ be disguised as four or five spaces), or possibly B) there is a tab, but nothing after it.

           

          Could you, please, post the data that resides in the variable #data#?  (If you need to redact certain bits, that's understood.)

           

          Also, I do believe that the attribute "attributes" is not a valid attribute for the cffile tag if the action is "read".  Adobe ColdFusion 9 * cffile action = "read"

           

          V/r,

           

          ^_^

          • 2. Re: getlistat error
            Alan Koenig_920 Level 1

            Text file has the following information.

            AHRI2806782
            HLRE201501158
            VERN201502452

             

            There will eventually be more than 20 fields of information going into the database.

             

            Once again.  Tank you for your help.

             

            Alan

            • 3. Re: getlistat error
              BKBK Adobe Community Professional & MVP

              Use the delimiters line-feed/carriage-return for the loop. You are treating each loop index i as a sublist, so the listGetAt function should take the tab as delimiter.

               

              <cffile action="read" file="http://website.com/test1.txt" variable="data">

               

              <cfloop index="i" list="#data#" delimiters= "#chr(10)##chr(13)#" >

               

              <cfquery datasource="X" username="Y" password="Z" timeout="90">

                  INSERT INTO property

                      (

                      PublicRemarks,

                      MLSID

                      )

                  VALUES

                      (

                      '#replace(listGetAt(i,1,chr(9)),'"','','all')#',

                      '#replace(listGetAt(i,2,chr(9)),'"','','all')#'

                      )

              </cfquery>

               

              </cfloop>

              • 4. Re: getlistat error
                Alan Koenig_920 Level 1

                Thank you.  This works and yet I am finding another problem. 

                I have no control of how the information goes into the database.  I can only pull the information out of the database through retsconnector.  My problem is that some of the fields will be blank. 

                MLS NumberBaths FullBaths HalfBeds TotalBuilding NameCityLand TenureList PriceMatrix Unique IDMLS Area MajorNeighbourhoodParking TotalPermit Address Internet YNPhoto CountProperty TypePublic RemarksStatusStreet NameStreet NumberStreet SuffixMaintenance ExpensePostal CodeSqft Total
                28067821032275.001337510METROKALIHI VALLEY200RNTSERENE AND COOL KALIHI VALLEY.  LOCATED ON A PRIVATE ROAD.  DOWNSTAIR AVAILABLE 6/1/2008.  RENOVATED.  FURNISHED WITH REFRIGERATOR, MICROWAVE, WASHER & DRYER.  WATER, BASIC CABLE INCLUDED.  TENANT HAVE SEPARATE ELECTRIC METER.  START SHOWING BY 1ST WEEK OF MAY.  BY APPT ONLY.A1088

                Above is a single row of what I am attempting to inport.  Some of the fields are blank and CF seems to only read the filled in spaces.   How do I include the blank spaces?

                 

                Thank you in advance.

                • 5. Re: getlistat error
                  BKBK Adobe Community Professional & MVP

                  Please kindly mark your original problem as solved and then create a new thread for the new problem. You will then be helping to improve the forum as a source of information.

                  • 6. Re: getlistat error
                    Alan Koenig_920 Level 1

                    Thank you.  I have marked as answered and also started a new string.  I am including a to the new string.

                     

                    include blank space