Skip to content
Related Articles

Related Articles

Convert CSV to Excel using Pandas in Python
  • Last Updated : 02 Jul, 2020

Pandas can read, filter, and re-arrange small and large datasets and output them in a range of formats including Excel. In this article, we will be dealing with the conversion of .csv file into excel (.xlsx).

Pandas provide the ExcelWriter class for writing data frame objects to excel sheets.
Syntax:

final = pd.ExcelWriter('GFG.xlsx')

Example:

Sample CSV File:

python-csv-to-json






import pandas as pd
import numpy as np
  
  
# Reading the csv file
df_new = pd.read_csv('Names.csv')
  
# saving xlsx file
GFG = pd.ExcelWriter('Names.xlsx')
df_new.to_excel(GFG, index = False)
  
GFG.save()

Output:

python-csv-to-excel

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :