-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_posts.py
More file actions
41 lines (37 loc) · 1.17 KB
/
create_posts.py
File metadata and controls
41 lines (37 loc) · 1.17 KB
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
import csv
clean = lambda s: s.rstrip().lstrip().replace('\n','').replace('\r\n','')
def get_post(title, id, difficulty, tags, abstract, paper, datasets,code):
dataset_str = '\n\n'.join([f'[{d.lower()}]({d.lower()})' for d in datasets])
tag_str = '\n'.join(['- ' + clean(tag) for tag in tags])
return f'''\
---
layout: post
author:
name: Paper ID {id}
difficulty: Difficulty - {difficulty}
share: true
title: {title}
categories:
{tag_str}
- {difficulty.lower()}
tags: []
---
**Abstract** - {abstract}
**Paper** - [{paper}]({paper})
**Code** - [{code}]({code})
**Dataset -** {dataset_str}
'''
with open('NNFL-papers.csv') as f:
data = list(csv.reader(f))
id = 0
for row in sorted(data[1:]):
ta, ta_email, title, abstract, paper, difficulty, tags, deliverables, code, datasets = row
if title:
title = title.rstrip().lstrip().replace(":","-").replace("\n"," ")
datasets = datasets.split(',')
tags = tags.split(',')
id += 1
with open(f'_posts/2021-10-31-{title.replace(" ", "-")}.md','w') as pf:
pf.write(get_post(title, id, difficulty, tags, abstract, paper, datasets,code))
#break
print('total: ',id)