gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
format my code: notworking = [] Iterate over each row in the DataFrame for i, row in…
- User
format my code: not_working = []
Iterate over each row in the DataFrame
for i, row in df_with_status.iterrows(): # Open a file in 'append' mode to log progress f = open("progress.txt", 'a')
code# Print and write the progress in the log file print("Progress " + str(i) + "/" + str(len(df_with_status))) f.write("Progress " + str(i) + "/" + str(len(df_with_status)) + "\n") file_type = False f.write('Starting ' + row['file_name']) # Check if the current file has already been completed if(row['completed']): f.write('Skipping attachment ' + row['file_name'] + " because it was already completed.") # Move to the next iteration of the loop continue # Determine the file type based on the file extension if(row['file_name'][-3:] == 'msg'): file_type = 'msg' if(row['file_name'][-3:] == 'pdf'): file_type = 'pdf' if(row['file_name'][-3:] == 'docx'): file_type = 'docx' # If the file type is not determined, skip the file if not file_type: f.write('Skipping ' + row['file_name'] + " because it is not a pdf nor a msg nor a docx." + "\n") # Move to the next iteration of the loop continue directory = './tmp/' if not os.path.exists(directory): os.makedirs(directory) temp_file_path = directory + 'temp_' + row['file_name'] try: blob_service_client.get_blob_to_path('inquiry'+str(row['inquiry_id']), row['file_name'], temp_file_path) f.write('Downloaded ' + row['file_name'] + ' to ' + temp_file_path + "\n") except Exception as err: f.write("Download Failed for " + row['file_name'] + "\n") df_with_status['errors'][i] = "Download Failed for" + row['file_name'] not_working.append(row) f.write(str(err) + "\n") continue - Assistant
not_working = []
Iterate over each row in the DataFrame
for i, row in df_with_status.iterrows(): # Open a file in 'append' mode to log progress f = open("progress.txt", 'a')
code