Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
I'd like to create a python script that reads .CSV bank statements, that collates a list…
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
I'd like to create a python script that reads .CSV bank statements, that collates a list of people I have paid money to and the amount of money I have paid to them in the statement. I would like that data to be saved into a new .CSV file. Could you write me some code that would do that?
- Assistant
Sure, could you show me a sample of what your bank statements look like? It doesn't have to be real data, I just need to know the format.
- User
The following list describes the schema for each column:
- "Transaction Date" - an ISO 8601 date
- "Account" - friendly name for the account from which funds were withdrawn (e.g. "Checking")
- "Payee" - name of the recipient of funds
- "Amount" - an amount of US dollars that the transaction represents. Payments are represented as negative values and are presented in parenthesis and with customary use of US number separation. For example, a payment of 1,234.56)".
- Assistant
from collections import defaultdict def collate_payments(file_in, file_out): # Initialize a dictionary to store the collated payments payments = defaultdict(float) # Read the bank statements from the input file with open(file_in, "r") as f_in: reader = csv.DictReader(f_in) # Iterate over each row in the .CSV file for row in reader: # Extract the date, account, payee, and amount from the row date = row["Transaction Date"] account = row["Account"] payee = row["Payee"] amount = float(row["Amount"].strip("($)")) # Keep track of the payments made to each payee payments[payee] += amount # Write the collated payments to the output file with open(file_out, "w") as f_out: writer = csv.writer(f_out) # Write a header row writer.writerow(["Payee", "Amount"]) # Write a row for each payee for payee, amount in payments.items(): writer.writerow([payee, amount]) # Example usage collate_payments("bank_statements.csv", "collated_payments.csv")This code assumes that the input .CSV file contains the bank statements, and that each row in the file represents a single transaction.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)