Using xlsxwriter, write a script that will take an int in cell A1 then span this number…
- User
Using xlsxwriter, write a script that will take an int in cell A1 then span this number of columns prefixed by str "Asset"
Assistant
Here's a script that uses the
xlsxwritermodule to create a spreadsheet with a number in cell A1 and then creates columns with the header "Asset" followed by an incrementing number for the number of columns specified in cell A1:import xlsxwriter # Create a workbook and select the active worksheet workbook = xlsxwriter.Workbook('assets.xlsx') worksheet = workbook.add_worksheet() # Get the number of columns from cell A1 num_columns = int(input("Enter the number of columns: ")) # Write the number of columns to cell A1 worksheet.write(0, 0, num_columns) # Create columns with headers "Asset" followed by an incrementing number for i in range(1, num_columns + 1): worksheet.write(0, i, f"Asset{i}") # Save the workbook workbook.close() print("The spreadsheet has been created.")Note: This script assumes that the module is already installed. If it's not, you can install it using .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.