On 1 December 2013 11:38, Amir Ladsgroup <ladsgroup(a)gmail.com> wrote:
2- use readlines:
import codecs
site=wikipedia.getSite()
f=codecs.open("file.txt","r","utf-8")
for line in f.readlines():
line=line.replace("\n","").replace("\r","")
name=line.split(":")[0] #or any kind that you like to get the title
page=wikipedia.Page(site,name)
#do whatever you like with the page
You can read the file per-line using 'for line in f' -- this will just read
the current line in memory. Cleaning up the rest a bit results in:
import codecs, wikipedia # or pywikibot if you are using core
site = wikipedia.getSite() # or pywikibot.Site() if you are using core
f = codecs.open("file.txt", "r", "utf-8")
for line in f:
line = line.strip()
name, definition = line.split(":", 1)
page = wikipedia.Page(site, name)
page.put(definition) # probably something else, though.
If you need some more assistance, I'd suggest joining #pywikipediabot on
irc.freenode.net -- it's typically quicker than e-mail :-)
Merlijn