def restart_harvest(args):
harvest = get_harvest(args)
data_dir = os.path.join(os.getcwd(), 'data', harvest)
meta = get_metadata(data_dir)
if meta:
try:
with open(os.path.join(data_dir, 'results.csv'), 'rb') as csv_file:
reader = csv.reader(csv_file, delimiter=',', encoding='utf-8')
rows = list(reader)
if len(rows) > 1:
start = len(rows) - 2
# Remove the last row in the CSV just in case there was a problem
rows = rows[:-1]
with open(os.path.join(data_dir, 'results.csv'), 'wb') as csv_file:
writer = csv.writer(csv_file, delimiter=',', encoding='utf-8')
for row in rows:
writer.writerow(row)
else:
start = 0
except IOError:
# Nothing's been harvested
start = 0
start_harvest(data_dir=data_dir, key=meta['key'], query=meta['query'], pdf=meta['pdf'], text=meta['text'], start=start, max=meta['max'])
评论列表
文章目录