convert excel file to csv with pandas 1

convert excel file to csv with pandas

import pandas as pd
import os

df = pd.read_excel('Book1.xlsx', sheet_name='Sheet1')
current_working_directory = os.getcwd()
save_path = current_working_directory + '\\file_name.csv'
df.to_csv(save_path)

Here is what the above code is Doing:
1. Read the excel file
2. Get the current working directory
3. Create a new path by adding the file name to the current working directory
4. Save the file to the new path

Similar Posts