-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25bb981
commit 9344012
Showing
10 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
import random | ||
|
||
unique=[] | ||
|
@@ -40,4 +41,4 @@ | |
if(counter>=6): | ||
break | ||
|
||
print(string) | ||
print(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import csv | ||
name = input('Name to delete :') | ||
# this is comment | ||
# hello rakesh this is comment | ||
""" this is multi line commnet""" | ||
|
||
records=[] | ||
found =0 | ||
file = open("student.csv","r") | ||
reader = csv.DictReader(file) | ||
for record in reader: | ||
record = dict(record) | ||
if(record['name']!=name): | ||
records.append(dict(record)) | ||
else: | ||
found =1 | ||
file.close() | ||
# Remove the old file and create a new csv file | ||
headers=['rollno','name','stream','fees'] | ||
file = open("student.csv","w") | ||
writer = csv.DictWriter(file,fieldnames =headers, lineterminator ='\n') | ||
writer.writeheader() | ||
writer.writerows(records) | ||
file.close() | ||
|
||
if(found==0): | ||
print(name, " does not exists") | ||
else: | ||
print(name," deleted successfully") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csv | ||
name = input('Name to Search :') | ||
|
||
file = open('student.csv','r') | ||
reader = csv.DictReader(file) | ||
found =0 | ||
for x in reader: | ||
x = dict(x) | ||
if(x['name']==name): | ||
print(name,' found in CSV file..') | ||
found =1 | ||
file.close() | ||
|
||
if(found == 0): | ||
print(name, ' not found....') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# program to update a record in csv file | ||
import csv | ||
name = input('Name to Update :') | ||
records = [] | ||
found = 0 | ||
file = open("student.csv", "r") | ||
reader = csv.DictReader(file) | ||
for record in reader: | ||
record = dict(record) | ||
if(record['name'] == name): | ||
record = dict(record) | ||
record['name'] =input('New Name:') | ||
records.append(record) | ||
found=1 | ||
else: | ||
records.append(dict(record)) | ||
file.close() | ||
|
||
# Remove the old file and create a new csv file | ||
pr | ||
headers = ['rollno', 'name', 'stream', 'fees'] | ||
file = open("student.csv", "w") | ||
writer = csv.DictWriter(file, fieldnames=headers, lineterminator='\n') | ||
writer.writeheader() | ||
writer.writerows(records) | ||
file.close() | ||
|
||
if(found == 0): | ||
print(name, " does not exists") | ||
else: | ||
print(name, " updated successfully") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csv | ||
records =[ | ||
["ID", "name", "Price", "Qty"], | ||
["102","LG Monitor","6500","20"], | ||
["103","KeyBoard","1350","156"], | ||
["105","Hp Mouse","650","120"], | ||
["106","Speaker","1670","136"] | ||
] | ||
|
||
f = open("stock.csv","w") | ||
csvwriter = csv.writer(f,lineterminator="\n") | ||
# csvwriter.writerow(header) | ||
csvwriter.writerows(records) | ||
f.close() | ||
print("Check your file now....") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csv | ||
headers =['rollno','name','stream','fees'] | ||
records = [ | ||
{'fees': 2356,'rollno': 12, 'name': 'surendra', 'stream': 'Humanities', }, | ||
{'rollno': 13, 'stream': 'Humanities', 'fees': 2356,'name': 'Ashok', }, | ||
{'rollno':15,'name':'Nipun','stream':'Humanities','fees':2356}, | ||
{'rollno': 22, 'name': 'Ayush Negi', 'fees': 2356,'stream': 'Science', }, | ||
] | ||
|
||
f = open("student.csv", "w") | ||
writer = csv.DictWriter(f, fieldnames = headers, lineterminator='\n') | ||
writer.writeheader() | ||
writer.writerows(records) | ||
f.close() | ||
print("Check your file now....") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ID,name,Price,Qty | ||
102,LG Monitor,6500,20 | ||
103,KeyBoard,1350,156 | ||
105,Hp Mouse,650,120 | ||
106,Speaker,1670,136 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
rollno,name,stream,fees | ||
12,surendra,Humanities,2356 | ||
13,Ashok Goyal,Humanities,2356 | ||
15,Nipun,Humanities,2356 | ||
22,Ayush Negi,Science,2356 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
target_list | ||
file = open("student.dat","w") | ||
writer = csv.DictWriter(file,fieldnames ="", lineterminator ='\n') |