human
1. Load data
assistant
#Here is the Python code you requested.
session = sibispy.Session()
if not session.configure():
    sys.exit()

slog.init_log(None, None, 
              'QC: Check all harvester-prepared CSVs are uploaded', 
              'check_unuploaded_files', None)
slog.startTimer1()

# Setting specific constants for this run of QC
api = session.connect_server('import_laptops', True)
primary_key = api.def_field

meta = api.export_metadata(format='df')
form_names = meta.form_name.unique().tolist()
if form is not None:
    # FIXME: This is incorrect - needs to reflect the short_to_long, etc.
    if not form in form_names:
        raise KeyError("{} not among Import Project forms".format(form))
    form_names_subset = [form]
else:
    form_names_subset = form_names

# # Taken from http://pycap.readthedocs.io/en/latest/deep.html#dealing-with-large-exports
# # and adapted to scope down to forms
# def chunked_export(project, form, chunk_size=100, verbose=True):
#     def chunks(l, n):
#         """Yield successive n-sized chunks from list l"""
#         for i in range(0, len(l), n):
#             yield l[i:i+n]
#     record_list = project.export_records(fields=[project.def_field])
#     records = [r[project.def_field] for r in record_list]
#     #print "Total records: %d" % len(records)
#     try:
#         response = None
#         record_count = 0
#         for record_chunk in chunks(records, chunk_size):
#             record_count = record_count + chunk_size
#             #print record_count
#             chunked_response = project.export_records(records=record_chunk, 
#                                                       fields=[project.def_field],
#                                                       forms=[form], 
#                                                       format='df',
#                                                       df_kwargs={'low_memory': False})
#             if response is not None:
#                 response = pd.concat([response, chunked_response], axis=0)
#             else:
#                 response = chunked_response
#    ...