Skip to content

Commit

Permalink
Pandas basics
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed May 28, 2018
1 parent a929e2f commit 2ade304
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Loops/Char_parallelogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def printString(string):
for i in range(0,n):
print(string[i],end=" ")

string = "TESTINGPROGRAM"
string = "TEST"
n = len(string)
# print(n)
for i in range(1,n+1):
Expand Down
2 changes: 1 addition & 1 deletion Text_Speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os

# The text that you want to convert to audio
mytext = 'Welcome to binarynote.com and this is really amazing my dear!'
mytext = 'My Baby samraddhi is playing with my mobile phone. Welcome to binarynote.com and this is really amazing my dear!'

# Language in which you want to convert
language = 'en'
Expand Down
Binary file modified __pycache__/turtle.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion database/delete_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

db = MySQLdb.connect("localhost","root","ramji","cable")

cursor = db.cursor();
cursor = db.cursor()

name = input("Enter any name")

Expand Down
50 changes: 44 additions & 6 deletions database/insert_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,47 @@
# Licence: MIT
#-------------------------------------------------------------------------------
import MySQLdb
db = MySQLdb.connect("localhost","root","ramji","cable")
cursor = db.cursor()
sql ="insert into customer values(20,'rakesh','jagdish','cf-4 arun vihar','12121212','arun@bin.com');"
cursor.execute(sql)
db.close()
print("Row inserted successfully")
from prettytable import PrettyTable

def del_record(cursor):
data = input("Enter something related to your record :")
sql = "delete from customer where name like '%"+data+"%' or fname like '%"+data+"%' or address like '%"+data+"%'"
sql = sql +" or phone like '%"+data+"%' or email like '%"+data +"%'"
cursor.execute(sql)

def show_result(cursor):
sql ="select * from customer"
cursor.execute(sql)
results = cursor.fetchall()
t = PrettyTable(['ID','Name','FatherName','Address','Phone','Email'])
for idr,name,fname,add,phone,email in results:
t.add_row([idr,name,fname,add,phone,email])
print(t)

def input_data(cursor):
admno = input("Enter Admno : ")
name = input("Enter student Name : ")
fname = input("Enter Father Name : ")
address = input("Enter Address : ")
phone = input ("Enter any valid Phone NO :")
email = input("Enter any valid Email ID : ")
""" create cursor to generate/ execute sql statement"""
sql = "insert into customer values (" + admno + ",'"+name+"','"+fname+"','"+address+"','"+phone+"','"+email+"');"
# print(sql)
cursor.execute(sql)

"""MAIN PROGRAM START FROM HERE """

if __name__=='__main__':
db = MySQLdb.connect("localhost","root","ramji","cable")
cursor = db.cursor()
# sql ="insert into customer values(20,'rakesh','jagdish','cf-4 arun vihar','12121212','arun@bin.com');"
# cursor.execute(sql)
input_data(cursor)
db.commit()
show_result(cursor)
del_record(cursor)
db.commit()
show_result(cursor)
db.close()

8 changes: 7 additions & 1 deletion database/select_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@
#-------------------------------------------------------------------------------

import MySQLdb
from prettytable import PrettyTable
# Open database connection
db = MySQLdb.connect("localhost","root","ramji","cable" )
cursor = db.cursor()
cnt = cursor.execute("select count(*) from customer")
sql ="select * from customer"
cursor.execute(sql)
results = cursor.fetchall()
#print( "ID Name Father Name Address")
print("\n Total records ",cnt)
t = PrettyTable(['ID','Name','FatherName','Address','Phone','Email'])
for idr,name,fname,add,phone,email in results:
#idr = record[0]
#name = record[1]
#fname = record[2]
#add = record[3]
print(idr,name,fname,add,phone,email)
t.add_row([idr,name,fname,add,phone,email])
# print(idr,name,fname,add,phone,email)
print(t)
db.close()
16 changes: 7 additions & 9 deletions fileHandling/Bulk_Image_Resizer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#-------------------------------------------------------------------------------
# Name: small images
# Purpose: Program to create small images
#
# Author: rakesh kumar
#
# Created: 09-02-2018
# Copyright: rakesh kumar
# Licence: Private use on one computer
# Name: small images
# Purpose: Program to create small images
# Author: rakesh kumar
# Created: 09-02-2018
# Copyright: rakesh kumar
# Licence website : http://www.cbsetoday.com
#-------------------------------------------------------------------------------
import os
import glob
Expand Down Expand Up @@ -48,7 +46,7 @@ def deleteFiles():
small(filename1,targetdir,filename)
#print filename

print ( "Job Complete " + str(count) + "....Check your folder now" )
print ( "\n\n\nJob Complete " + str(count) + "....Check your Destination folder now\n\n" )

if __name__ == '__main__':
deleteFiles()
3 changes: 2 additions & 1 deletion fileHandling/csvReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def writecell(ws,sub,marks,row):
except:
return

with open('result.csv','r') as csvfile:
with open('raju.csv','r') as csvfile:
csv_reader = csv.reader(csvfile)
wb = xlwt.Workbook()
ws = wb.add_sheet("result")
Expand Down Expand Up @@ -75,6 +75,7 @@ def writecell(ws,sub,marks,row):
# # for i in line3:
# # print(i, end=" ")
# # print();
# print(line)
ws.write(i,0,line3[0])
ws.write(i,1,line3[1]+' '+line3[2])
writecell(ws,line3[4],line3[5],i)
Expand Down
3 changes: 3 additions & 0 deletions pandas/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pandas as pd
pf = pd.read_excel('result.xls')
print(pf)
Loading

0 comments on commit 2ade304

Please sign in to comment.