I want to clean-up 12,000 wiki pages from this wiki category. For that, i am having all the 12,000 wikipages in a csv file. When my code runs, it modifies the page, one by one. How can i delete a previous row while reading a (next) row of a CSV file by python3 ? If it is possible, it will be easy to share the remaining rows of the csv file to another wiki contributor. Otherwise, i should manually open the csv file to delete 'the completed rows'.
My code as simplified;-
import csv
import pywikibot
with open('0.csv', 'r') as csvfile:
reader = csv.reader(csvfile,delimiter="~")
for row in reader:
#if len(row) == 8:
wikiPage1 = row[0]
indexPages = row[5]
print (wikiPage1)
site = pywikibot.Site('ta', 'wiktionary')
page1 = pywikibot.Page(site, wikiPage1)
page1.text = page1.text.replace('Number','எண்')
page1.save(summary=''Number --> எண்')
I learned from two web pages page-1, page-2 of this site.
The below code do this target;-
#-*- coding: utf-8 -*-
#bringing the needed library modules
import csv, time, subprocess
#subprocess.call("sed -i `` 1d 0-123.csv",shell=True)
WAIT_TIME = 10
with open('0-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 0-123.csv",shell=True)
wiktHeader1 = row[0]#.decode('utf-8')
print ()
print (wiktHeader1 + ' = படி-1: விக்சனரியின் தலைப்புச்சொல்.')
time.sleep(WAIT_TIME)