-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv_file.py
89 lines (49 loc) · 1.29 KB
/
csv_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
# coding: utf-8
# In[30]:
import csv
# In[31]:
text = open("username.csv", "r")
# In[32]:
with open('username.csv','r') as csv_file:
csv_reader=csv.reader(csv_file)
for line in csv_reader:
print(line)
# In[33]:
#join() method combines all contents of
# csvfile.csv and formed as a string
text = ''.join([i for i in text])
# In[52]:
# search and replace the contents
origin_word=input('Enter the origin word :')
replaced_word=input('Enter the replaced word :')
text = text.replace('{}'.format(origin_word),'{}'.format(replaced_word))
#text = text.replace("grey07", "grey")
#text = text.replace("Grey", "White")
# In[53]:
x = open("output.csv","w")
x.writelines(text)
x.close()
# In[54]:
with open('output.csv','r') as csv_file:
csv_reader=csv.reader(csv_file)
for line in csv_reader:
print(line)
# In[136]:
search_word =input('Enter the word you want to search : ')
flag=0
ls=[]
with open('username.csv','r') as csv_file:
csv_reader1=csv.reader(csv_file)
for line in csv_reader1:
for word in line:
a=word.split(';')
#a=str(a)
ls=ls+a
for item in ls:
if item in search_word:
print ('Found')
break
else:
print('Not Found')
# In[ ]: