Tuesday, April 30, 2024

python

 import datetime

import pandas as pd
import cx_Oracle
con = cx_Oracle.connect('SYSTEM/oracle123@localhost:1521/xe')
c = con.cursor()
sql = "select * from covid_data"
res = c.execute(sql)
t = pd.read_sql(sql,con)
t.to_csv(r'C:\Users\abc\covid.csv')
#t.to_csv(r'C:\Users\abc\covid.csv', mode='w')

Pandas.read_csv()
 
Pandas is a very popular data manipulation library, and it is very commonly used. One of it’s very important and mature functions is read_csv() which can read any .csv file very easily and help us manipulate it. Let’s do it on our 100-Sales-Record dataset.

This function is very popular due to its ease of use. You can compare it with our previous codes, and you can check it
import pandas as pd
pdDf = pd.read_csv('100 Sales Record.csv')
>>> pdDf.head()


Pandas.read_csv definitely offers a lot of other parameters to tune in our data set, for example in our convertcsv.csv file, we had no column names so we can read it as:

>>> newdf = pd.read_csv('convertcsv.csv', header=None)
>>> newdf.head()

No comments:

Post a Comment

tMap vs tJoin -Talend

  tMap is frequently used component for joins and lookup purpose, it is also use for verity of operations and transformations, whereas tJoin...