Skip to content

Instantly share code, notes, and snippets.

@esmitt
Created June 21, 2021 16:12
Show Gist options
  • Save esmitt/53776a5002541a71a0cbb017b5827412 to your computer and use it in GitHub Desktop.
Save esmitt/53776a5002541a71a0cbb017b5827412 to your computer and use it in GitHub Desktop.
Convert a .csv file into a Microsoft Excel .xlsx format. It is mandatory to install the package openpyxl and pandas
import sys
import pandas as pd
filename = sys.argv[1]
filename = filename[:-4]
read_file = pd.read_csv (filename + ".csv")
read_file.to_excel (filename + ".xlsx", index = None, header=True)
# run as
# python csv_to_xlsx.py %1
# where %1 is the name of the name of the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment