With security improvement to Excel, naming a .csv file .xls no longer works. Here is a small Python program to create a .xlsx file from a .csv file. You can execute this code from a BASIC program.
Usage: csv2xlsx.py filename.csv spreadsheet.xlsx
You will need to install openpyxl, pip install openpyxl
import sys
import csv
from openpyxl import Workbook
csvfilename = sys.argv[1]
excelfilename = sys.argv[2]
wb = Workbook()
ws = wb.active
with open(csvfilename) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=’,’)
for row in csv_reader:
ws.append(row)
wb.save(excelfilename)