Export scraped records to CSV and Excel
Writes a short script that exports scraped records to CSV and an Excel file with safe encoding, headers and no formula injection.
Task:
Write one short script in [language] that exports a list of scraped records to a CSV file and an Excel file.
Context:
Each record has the fields [field names] and I have about [number of records] records in [memory, JSON file or other form]. The files will be opened in [Excel, Google Sheets or other] by [who].
Rules:
- Use UTF-8 with a header row, and make sure accents and commas inside values survive.
- Keep dates as real dates and numbers as numbers in the Excel file.
- Guard against values that start with =, +, - or @ so a spreadsheet does not run them as formulas.
- Name the files with a date stamp and never overwrite an earlier export.
- Say which library you use and if you are unsure of a function name.
Result:
The complete script with comments, then 3 lines on how to run it and how to check the files opened correctly.