title: TypeError: list indices must be integers, not column
body: <p>I am getting the above error while running python code.
  Can you please help me to solve this?</p>
  
  <p>I am trying to run an SQL query and load the output file into an S3 bucket. But it is showing this error.</p>
  
  <p>Running the SQL query is based on a sequence number. Jobs will triggered consecutively which run the queries, generate the files and load them into my S3 bucket.</p>
  
  <p>Code:</p>
  
  <pre><code>def load_data():
      try:
  
          conn = redshift_conn()
  
          df_file = pd.read_csv("/medaff/Scripts/python/output_query.txt", 'r', delimiter = '|')
          print(df_file['tablename'][0])
  
          unique_seq_num = df_file['seq_no'].unique().tolist()
          unique_seq_num.sort()
          for exec_seq in unique_seq_num:
              temp_df = df_file[df_file['seq_no'] == exec_seq].copy()
              unique_table_name = temp_df['tablename'].unique().tolist()
              unique_sql_query = temp_df['sql'].unique().tolist()
              print(unique_table_name)
              #table_name = df_file['tablename'].unique()
              #sql = df_file['sql'].unique()
  
              for i in range(0,len(unique_table_name)):
                  print(unique_table_name[i])
                  #print(unique_sql_query[i])
  
                  with conn.cursor() as cur:
                      cur.execute(unique_sql_query[i])
                      res = cur.fetchall()
  
                      #print(res)
                      with open('/medaff/Scripts/python/' + unique_table_name[i] + '.txt' , 'w') as file:
                          d = csv.writer(file, delimiter='|')
                          d.writerow([i[0] for i in cur.description])
                          d.writerows(res)
  
                      print(unique_table_name[i])
                      print(bucket)
                      print(access_key)
                      print(secret)
                      print(" aws s3 cp /medaff/Scripts/python/{}.txt s3://{}/{}/ --sse".format(unique_table_name[i], bucket, unique_table_name[i]))
                      os.system(" aws s3 cp /medaff/Scripts/python/{0}.txt s3://{1}/{2}/ --sse".format(unique_table_name[i], bucket, unique_table_name[i]))
  
  
                      cur.execute(" truncate table medaff.{} ".format(unique_table_name[i]))
                      print(" truncate table medaff.{} ".format(unique_table_name[i]))
                      cur.execute(" COPY medaff.{0} FROM 's3://{1}/{2}/{3}.txt' CREDENTIALS 'aws_access_key_id={4};aws_secret_access_key={5}'emptyasnull blanksasnull  DELIMITER ',' IGNOREHEADER 1 DATEFORMAT 'auto'ENCODING AS UTF8 acceptinvchars COMPUPDATE OFF  CSV; ".format(unique_table_name[i], bucket, unique_table_name[i], unique_table_name[i], access_key, secret))
                      print(" COPY medaff.{0} FROM 's3://{1}/{2}/{3}.txt' CREDENTIALS 'aws_access_key_id={4};aws_secret_access_key={5}'emptyasnull blanksasnull  DELIMITER ',' IGNOREHEADER 1 DATEFORMAT 'auto'ENCODING AS UTF8 acceptinvchars COMPUPDATE OFF  CSV; ".format(unique_table_name[i], bucket, unique_table_name[i], unique_table_name[i], access_key, secret))
  
                      '''load_query = ("insert into {} values {}".format(unique_table_name[i], res))
                      cur.execute(load_query)
                      final_res = cur.fetchall()
                      count = final_res.count()
                      print(count)'''
  
      except Exception as ex:
          print(ex)
          traceback.print_exc()
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "iMedical_Consump_Load_Procs.py", line 79, in load_data
    print(unique_table_name[i])  
  TypeError: list indices must be integers, not Column
  </code></pre>