Export to a CSV File - The Advantages of Learning Python Programming for Beginners: A Comprehensive Guide

Latest

Dive into the world of Python programming with our comprehensive resources

Music

logo

Saturday, January 28, 2023

Export to a CSV File

 

In this article we will export to a csv file. Type the following code in the command line to install Pandas and install Pandas.

py -3.9 -m pip install pandas

 


 

 

 

 

Figure 1




 

 

 

 

 

 

 

 

Figure 2

 

import pandas as pd

 

data = {

        'Id': [1,2,3,4,5,6,7,8,9,10,11,12,13],

        'FirstName': ['Bahadir','Melissa','Tommy','Alice','Michael','Mike','Tracy','Nancy','Jack','Alina','Joe','Johanna','Emilia'],

        'LastName': ['Sahin','Parker','Paton','May ','Alon','Carson','Abbot','White','Fox','Benson','Eagle','Manson','Peterson'],

        'Mail': ['basahin@hotmail.com','melparker@gmail.com','tommypat@hotmail.com','alicemay12@hotmail.com','michaelal57@gmail.com',

                 'mikecarson33@hotmail.com','tracyabbot82@hotmail.com','nancywh@gmail.com','jackfox89@hotmail.com','alinabens2@hotmail.com',

                 'joeeagle7@gmail.com','johannamans@hotmail.com','emiliapets@hotmail.com'],

        }

 

dataFrame = pd.DataFrame(data, columns= ['Id', 'FirstName','LastName','Mail'])

 

dataFrame.to_csv (r'C:\Data\export_person.csv', index = False, header=True)

 

print (dataFrame)

 

 

I have come to the end of this article. See you in my next article. Happy coding. Bahadir Sahin

No comments:

Post a Comment

Featured post

Python Introduction

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built ...