#-*- coding: utf-8 -*-
#fetching the needed library modules
import csv, subprocess, time, pywikibot, re
WAIT_TIME = 15
with open('123.csv', 'r') as csvfile:
reader = csv.reader(csvfile,delimiter="~")
for row in reader:
#removing the first line of the csv
subprocess.call("sed -i `` 1d 123.csv",shell=True)
wiktHeader = row[0]#.decode('utf-8')
print (wiktHeader)
site1 = pywikibot.Site('ta', 'wiktionary')
page = pywikibot.Page(site1, wiktHeader)
# print (page.text)
page.text = page.text
#checking categories if not placing categories
findWord1 = '.'#.decode('utf-8')
findCat1 = '[[பகுப்பு:ஆங்கிலம்-புள்ளியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord1 in wiktHeader:
if not findCat1 in page.text:
page.text = page.text + '\n' + findCat1
findWord2 = '('#.decode('utf-8')
findCat2 = '[[பகுப்பு:ஆங்கிலம்-வளைவுக்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord2 in wiktHeader:
if not findCat2 in page.text:
page.text = page.text + '\n' + findCat2
findWord3 = ')'#.decode('utf-8')
findCat3 = '[[பகுப்பு:ஆங்கிலம்-வளைவுக்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord3 in wiktHeader:
if not findCat3 in page.text:
page.text = page.text + '\n' + findCat3
findWord4 = '/'#.decode('utf-8')
findCat4 = '[[பகுப்பு:ஆங்கிலம்-முன்சாய்வுக்கோடுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord4 in wiktHeader:
if not findCat4 in page.text:
page.text = page.text + '\n' + findCat4
findWord5 = '-'#.decode('utf-8')
findCat5 = '[[பகுப்பு:ஆங்கிலம்-சொல்லிடையிணைப்புக்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord5 in wiktHeader:
if not findCat5 in page.text:
page.text = page.text + '\n' + findCat5
findWord6 = 'இணையப் பல்கலைக்கழக அகரமுதலியில்'#.decode('utf-8')
findCat6 = '[[பகுப்பு:ஆங்கிலம்-கொடை-2010-தஇகக-சுந்தர் தானியங்கி]]'#.decode('utf-8')
if findWord6 in page.text:
if not findCat6 in page.text:
page.text = page.text + '\n' + findCat6
findWord7 = '_'#.decode('utf-8')
findCat7 = '[[பகுப்பு:ஆங்கிலம்-கூட்டுச்சொல் தலைப்புகள்]]'#.decode('utf-8')
if findWord7 in page.text:
if not findCat7 in page.text:
page.text = page.text + '\n' + findCat7
# findWord8 = ' '#.decode('utf-8')
# findCat8 = '[[பகுப்பு:ஆங்கிலம்-கூட்டுச்சொல் தலைப்புகள்]]'#.decode('utf-8')
# if findWord8 in page.text:
# if not findCat8 in page.text:
# page.text = page.text + '\n' + findCat8
findWord9 = '’'#.decode('utf-8')
findCat9 = '[[பகுப்பு:ஆங்கிலம்-காற்புள்ளியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord9 in wiktHeader:
if not findCat9 in page.text:
page.text = page.text + '\n' + findCat9
findWord10 = "'"#.decode('utf-8')
findCat10 = '[[பகுப்பு:ஆங்கிலம்-மேற்கோட்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord10 in wiktHeader:
if not findCat10 in page.text:
page.text = page.text + '\n' + findCat10
findWord11 = '"'#.decode('utf-8')
findCat11 = '[[பகுப்பு:ஆங்கிலம்-மேற்கோட்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord11 in wiktHeader:
if not findCat11 in page.text:
page.text = page.text + '\n' + findCat11
findWord12 = '“'#.decode('utf-8')
findCat12 = '[[பகுப்பு:ஆங்கிலம்-மேற்கோட்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord12 in wiktHeader:
if not findCat12 in page.text:
page.text = page.text + '\n' + findCat12
findWord13 = "‘"#.decode('utf-8')
findCat13 = '[[பகுப்பு:ஆங்கிலம்-மேற்கோட்குறியுள்ள தலைப்புகள்]]'#.decode('utf-8')
if findWord13 in wiktHeader:
if not findCat13 in page.text:
page.text = page.text + '\n' + findCat13
# findWord7 = "*[http://www.tamilvu.org/slet/servlet/o33.o33searh?CboSelect=1&TxtSearch="+wiktHeader+"&OptSearch=&id=All தமிழ் இணையப் பல்கலைக்கழக அகரமுதலியிலில் "+wiktHeader+"]"
#removing unwanted words, templates
#.replace(s,r)
# s = ''#.decode('utf-8')
# r = ''#.decode('utf-8')
s1 = '==ஆங்கிலம்==\n'#.decode('utf-8')
r1 = '=={{மொழி|en}}==\n'#.decode('utf-8')
s2 = ';பலுக்கல்\n\n'#.decode('utf-8')
r2 = ''#.decode('utf-8')
s3 = '* {{audio|en-us-{{PAGENAME}}.ogg|பலுக்கல் (ஐ.அ)}}'#.decode('utf-8')
r3 = ''#.decode('utf-8')
s4 = '==உசாத்துணை=='#.decode('utf-8')
r4 = '\n{{ஆதாரங்கள்-தஇககலை}}'#.decode('utf-8')
s5 = '\n* தமிழ்'#.decode('utf-8')
r5 = ''#.decode('utf-8')
s6 = '* தமிழ்'#.decode('utf-8')
r6 = '\n{{ஆதாரங்கள்-தஇககலை}}'#.decode('utf-8')
s7 = "*"#.decode('utf-8')
r7 = "#"#.decode('utf-8')
s8 = '}}=={{'#.decode('utf-8')
r8 = '}}==\n{{'#.decode('utf-8')
s9 = '].'#.decode('utf-8')
r9 = ']'#.decode('utf-8')
s10 = '{{ஒலிப்பு1}}\n'#.decode('utf-8')
r10 = ''#.decode('utf-8')
s11 = ":*{{உச்சரிப்புதவி|'''*'''}}{{audio|En-us-{{PAGENAME}}.ogg| [[File:Flag of the United States.svg|24px]]}}\n"#.decode('utf-8')
r11 = ""#.decode('utf-8')
s12 = '{{சென்னைப் பேரகரமுதலி}}'#.decode('utf-8')
r12 = ''#.decode('utf-8')
s13 = "'''{{PAGENAME}}''', {{பெயர்ச்சொல்}}."#.decode('utf-8')
r13 = "{{பெயர்ச்சொல்-பகுப்பு|en}}"#.decode('utf-8')
s14 = ':*'#.decode('utf-8')
r14 = '#'#.decode('utf-8')
s15 = "#{{உச்சரிப்புதவி|'''*'''}}{{audio|En-us-{{PAGENAME}}.ogg| [[File:Flag of the United States.svg|24px]]}}\n"#.decode('utf-8')
r15 = ""#.decode('utf-8')
s16 = '# '#.decode('utf-8')
r16 = '#'#.decode('utf-8')
s17 = ":*{{உச்சரிப்புதவி|'''/æ.læˈkɑː(ɹ)t/'''}}{{audio|En-us-{{PAGENAME}}.ogg| [[File:Flag of the United States.svg|24px]]}}\n"#.decode('utf-8')
r17 = "உச்சரிப்புதவி|'''/æ.læˈkɑː(ɹ)t/'''}}{{audio|En-us-{{PAGENAME}}.ogg| [[File:Flag of the United States.svg|24px]]}}\n"#.decode('utf-8')
s18 = ':*{{உச்சரிப்புதவி|'#.decode('utf-8')
r18 = ''#.decode('utf-8')
s19 = "'''*'''}}\n"#.decode('utf-8')
r19 = ''#.decode('utf-8')
s20 = '{{audio|En-us-{{PAGENAME}}.ogg| [[File:Flag of the United States.svg|24px]]}}\n'#.decode('utf-8')
r20 = ''#.decode('utf-8')
s21 = "'''#'''}}\n"#.decode('utf-8')
r21 = ''#.decode('utf-8')
s22 = ':#{{உச்சரிப்புதவி|'#.decode('utf-8')
r22 = ''#.decode('utf-8')
s23 = "'''#'''}}"#.decode('utf-8')
r23 = ""#.decode('utf-8')
s24 = ':#'#.decode('utf-8')
r24 = '#'#.decode('utf-8')
s25 = "{{உச்சரிப்புதவி|}}{{ஆங்பலு}} ''ஒலிப்பு:''"#.decode('utf-8')
r25 = ""#.decode('utf-8')
s26 = '{{ஆங்-சொற்பிற}}'#.decode('utf-8')
r26 = ''#.decode('utf-8')
s27 = '#['#.decode('utf-8')
r27 = '*['#.decode('utf-8')
s28 = '[[படிமம்:'#.decode('utf-8')
r28 = '[[File:'#.decode('utf-8')
s29 = ';[[பலுக்கல்]] {{audio|en-us-{{PAGENAME}}.ogg|(ஐ.அ)}}'#.decode('utf-8')
r29 = ''#.decode('utf-8')
s30 = ';பலுக்கல் {{audio|en-us-{{PAGENAME}}.ogg|(ஐ.அ)}}'#.decode('utf-8')
r30 = ''#.decode('utf-8')
s31 = '[[பகுப்பு:ஆங்கிலம்-சொல்லிடையிணைப்புக்குறி உள்ளவை]]'#.decode('utf-8')
r31 = ''#.decode('utf-8')
s32 = '*[['#.decode('utf-8')
r32 = '#[['#.decode('utf-8')
s33 = '===பலுக்கல்===\n\n'#.decode('utf-8')
r33 = ''#.decode('utf-8')
s34 = '{{ஆங்கில ஆதாரங்கள்|தமிழிணையக் கல்விக்கழக, கலைச்சொல் [[பேரகரமுதலி]]யின் {{த.இ.க.க.சொற்தேடல்பக்கம்}}}}'#.decode('utf-8')
r34 = '{{ஆதாரங்கள்-தஇககலை}}'#.decode('utf-8')
# s35 = findWord7 #.decode('utf-8')
# r35 = "{{ஆதாரங்கள்-தஇககலை}}"#.decode('utf-8')
# s36 = '[http://ta.wiktionary.org/wiki/%E0%AE%B5%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%9A%E0%AE%A9%E0%AE%B0%E0%AE%BF:%E0%AE%85%E0%AE%9F%E0%AE%BF%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%88_%E0%AE%86%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%B2%E0%AE%9A%E0%AF%8D_%E0%AE%9A%E0%AF%8A%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D விக்சனரி:அடிப்படை ஆங்கிலச் சொற்களுள்ளப் பக்கம்]'#.decode('utf-8')
# r36 = '[[விக்சனரி:அடிப்படை ஆங்கிலச் சொற்கள்]]'#.decode('utf-8')
s37 = '{{ஆதாரங்கள்-தஇககலை}}\n{{ஆதாரங்கள்-தஇககலை}}' #.decode('utf-8')
r37 = '{{ஆதாரங்கள்-தஇககலை}}'#.decode('utf-8')
s38 = '{{த.இ.க.க.}}'#.decode('utf-8')
r38 = ''#.decode('utf-8')
s39 = '[[பகுப்பு:ஆங்கிலம்-வளைவுக்குறியுள்ள சொற்கள்]]'#.decode('utf-8')
r39 = ''#.decode('utf-8')
s40 = '[[பகுப்பு:ஆங்கிலம்-முன்சாய்வுக்கோடுள்ள சொற்கள்]]'#.decode('utf-8')
r40 = ''#.decode('utf-8')
s41 = '[[பகுப்பு:ஆங்கிலம்-புள்ளியுள்ள சொற்கள்]]'#.decode('utf-8')
r41 = ''#.decode('utf-8')
s42 = '{{ஆதாரங்கள்-மொழி|ta}}'#.decode('utf-8')
r42 = ''#.decode('utf-8')
s43 = '{{ஆங்-பலுகுறிஒலி| #}}'#.decode('utf-8')
r43 = ''#.decode('utf-8')
s44 = '{{ஆங்-பலுகுறிஒலி| }}'#.decode('utf-8')
r44 = ''#.decode('utf-8')
s45 = '{{ஆங்-பலுகுறிஒலி|}}'#.decode('utf-8')
r45 = ''#.decode('utf-8')
s46 = '[[பகுப்பு:ஆங்கிலம்-கூட்டுச்சொற்கள்]]'#.decode('utf-8')[[பகுப்பு: ஆங்கிலம்-கூட்டுச்சொற்கள்]]
r46 = ''#.decode('utf-8')
s47 = ']]\n\n[[பகுப்பு:'#.decode('utf-8')
r47 = ']]\n[[பகுப்பு:'#.decode('utf-8')
s48 = ']]\n\n\n[[பகுப்பு:'#.decode('utf-8')
r48 = ']]\n[[பகுப்பு:'#.decode('utf-8')
s49 = '* {{audio|en-us-{{PAGENAME}}.ogg|ஒலிப்பு (ஐ.அ)}}'#.decode('utf-8')
r49 = ''#.decode('utf-8')
s50 = '[[பகுப்பு: ஆங்கிலம்-கூட்டுச்சொற்கள்]]'#.decode('utf-8')
r50 = ''#.decode('utf-8')
existingContent = page.text.replace(s1,r1).replace(s2,r2).replace(s3,r3).replace(s4,r4).replace(s5,r5).replace(s6,r6).replace(s7,r7).replace(s8,r8).replace(s9,r9).replace(s10,r10).replace(s11,r11).replace(s12,r12).replace(s13,r13).replace(s14,r14).replace(s15,r15).replace(s16,r16).replace(s17,r17).replace(s18,r18).replace(s19,r19).replace(s20,r20).replace(s21,r21).replace(s22,r22).replace(s23,r23).replace(s24,r24).replace(s25,r25).replace(s26,r26).replace(s27,r27).replace(s28,r28).replace(s29,r29).replace(s30,r30).replace(s31,r31).replace(s32,r32).replace(s33,r33).replace(s34,r34).replace(s37,r37).replace(s38,r38).replace(s39,r39).replace(s40,r40).replace(s41,r41).replace(s42,r42).replace(s43,r43).replace(s44,r44).replace(s45,r45).replace(s46,r46).replace(s47,r47).replace(s48,r48).replace(s49,r49).replace(s50,r50)#.replace(s5,r5)
removeLine1 = " இணையப் பல்கலைக்கழக அகரமுதலியில்\s*\[.*\]"#.decode('utf-8')
modifiedContent1 = re.sub(removeLine1, '' , existingContent)
# print(modifiedContent1)
catSummary = '''-[[பகுப்பு:அறுபட்ட கோப்பு இணைப்புகள் உள்ள பக்கங்கள்|அறுபட்ட இணைப்பு நீக்கம்]], + [[பகுப்பு:ஆங்கிலம்-கூட்டுச்சொல் தலைப்புகள்|பகுப்பு மாற்றம்]]'''#.decode('utf-8')
page.text = modifiedContent1.strip()
print (modifiedContent1)
page.save(summary = catSummary)
time.sleep(WAIT_TIME)