Export CSV to Excel File in Python with Visual Studio Code on Windows - DevPops-Inc/windows GitHub Wiki

• Press the Windows key, type “visual studio code” and select “Open.”
image

• Press the Ctrl and N key to create a new file.
image

• Select “Select a Language.”
image

• Type “python” in the search box and select “Python (python)” from the result.
image

• Type import pandas as pd and press the Enter key to import the Pandas module as the pd variable.
image

• Type from openpyxl.workbook import Workbook and press the Enter key twice to import the Workbook object from the openpxl.workbook module.
image

• Type df_csv = pd.read_csv(‘< .csv file >.csv’, header=None) and press the Enter key to define the dataframe for the .csv file.
image

• Type df_csv.colums = [‘< colunmn 1 >’, ‘< column 2 >’, ‘< . . . >’ ] and press the Enter key to define the columns.
image

• Type print(df_csv) and press the Enter key to print the .csv file.
image

• Press the Ctrl and S keys to save the file.
image

• Browse to where you want to save the file, type the filename in the “File name:” box and select “Save.”
image

• Press the Run button to print the contents of the .csv file in the TERMINAL.
image

• Click on the last line in the editor, type df_csv.to_excel(‘< Excel filename >’.xlsx’) and press the Enter key to export the .csv file to a new Excel file.
image

• Press the Run button to export the Excel file.
image

• Browse to the location of the new Excel file and double-click it.
image

• The contents from the .csv file will be in the Excel file you’ve just exported.
image

⚠️ **GitHub.com Fallback** ⚠️