(800) 219-8613 sales@ashwoodcomputer.com

Short Python code to create an excel file from a .csv file

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:

Ashwood Computer, Inc.

10671 Techwoods Circle Cincinnati, Ohio 45242

(800) 219-8613
(513) 563-2800

(513) 554-6412

Our Value – Added

Ashwood Computer, Inc. provides quality products and services that consistently meet our customer’s requirements, while continually searching for ways to improve them.

Our experienced project managers will help you successfully accomplish your goals on time and with optimum results! Our continuing success is attributed to the diverse backgrounds of our technical staff and our overall company drive for Total Customer Satisfaction!

ForeMost ERP is an impressive new ‘Hybrid’ Solution developed utilizing our mvTools.
ForeMost is dramatically improving our customers information systems and business operations. Moreover ForeMost provides our customers a significant competitive advantage!

© 2021 Ashwood Computer, Inc.
Ashwood Computer adheres to ISO 9001:2008 standards, a quality management system recognized around the world for quality design and production.