title: ListGetAt Issues when parsing CSV file
body: <p>I have a script that is reading CSV files from clients and is splitting the values into variables that will later on enter the database.</p>
  
  <p>This is the error I am getting when a CSV comes in with less columns than the required minimum.</p>
  
  <pre><code>In function ListGetAt(list, index [, delimiters]), the value of index, 11, is not a valid as the first argument (this list has 10 elements). Valid indexes are in the range 1 through the number of elements in the list.
  
  Expression
  
  Invalid list index 11. 
  </code></pre>
  
  <p>This is a sample of the code</p>
  
  <pre><code>    &lt;cfscript&gt;
              csvData = csvloaderCFC.loadCSVfile(csvfilename);
      &lt;/cfscript&gt;
  
  
  
      &lt;cfset i=0&gt;
  
  
  
  &lt;!---  loop CSV Data ----&gt;
  
  &lt;cfloop index="line" list="#csvData#" delimiters="#chr(10)##chr(13)#"&gt;
  
  &lt;!---  Ignore 1st Row ----&gt;
          &lt;cfif i EQ 0&gt;
              &lt;cfset i++&gt;
                &lt;cfscript&gt;
                  continue;
              &lt;/cfscript&gt;
           &lt;/cfif&gt;
  
                         &lt;!--- Split CSV file ---&gt;
             &lt;cfscript&gt;
             line = csvloaderCFC.listfix(line);
              ClientBrandID =  (listgetAt('#line#',1) EQ 'NULL')?'':listgetAt('#line#',1);
              SurveyType =  (listgetAt('#line#',2) EQ 'NULL')?'':listgetAt('#line#',2);
              Location= (listgetAt('#line#',3) EQ 'NULL')?'':listgetAt('#line#',3);
              ClientContactID =  (listgetAt('#line#',4) EQ 'NULL')?'':listgetAt('#line#',4);
              FirstName=  (listgetAt('#line#',5) EQ 'NULL')?'':listgetAt('#line#',5);
              LastName=  (listgetAt('#line#',6) EQ 'NULL')?'':listgetAt('#line#',6);
              HomePhone=  (listgetAt('#line#',7) EQ 'NULL')?'':listgetAt('#line#',7);
              WorkPhone=  (listgetAt('#line#',8) EQ 'NULL')?'':listgetAt('#line#',8);
              CellPhone=  (listgetAt('#line#',9) EQ 'NULL')?'':listgetAt('#line#',9);
              Email =  (listgetAt('#line#',10) EQ 'NULL')?'':listgetAt('#line#',10);
              BirthDate= (listgetAt('#line#',11) EQ 'NULL')?'':listgetAt('#line#',11);
              Zip= (listgetAt('#line#',12) EQ 'NULL')?'':listgetAt('#line#',12);
              Gender= (listgetAt('#line#',13) EQ 'NULL')?'':listgetAt('#line#',13);
              InquiryDate= (listgetAt('#line#',14) EQ 'NULL')?'':listgetAt('#line#',14);
              ScheduledBy= (listgetAt('#line#',15) EQ 'NULL')?'':listgetAt('#line#',15);
              ConsultServiceType= (listgetAt('#line#',16) EQ 'NULL')?'':listgetAt('#line#',16);
              ConsultDate= (listgetAt('#line#',17) EQ 'NULL')?'':listgetAt('#line#',17);
              ConsultantName= (listgetAt('#line#',18) EQ 'NULL')?'':listgetAt('#line#',18);
              ServiceType= (listgetAt('#line#',19) EQ 'NULL')?'':listgetAt('#line#',19);
              ServiceDate= (listgetAt('#line#',20) EQ 'NULL')?'':listgetAt('#line#',20);
              ServiceProviderName= (listgetAt('#line#',21) EQ 'NULL')?'':listgetAt('#line#',21);
              ServiceRevenue= (listgetAt('#line#',22) EQ 'NULL')?'':listgetAt('#line#',22);
              LeadSource= (listgetAt('#line#',23) EQ 'NULL')?'':listgetAt('#line#',23);
  
              &lt;/cfscript&gt;
  
  &lt;!--- SQL Code begins here ---&gt;
  </code></pre>
  
  <p>I need to modify my code to be able to process smaller files regarding if they include all of the columns or not because those are valuable information as well.</p>