-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd2xlsx.py
More file actions
27 lines (26 loc) · 743 Bytes
/
md2xlsx.py
File metadata and controls
27 lines (26 loc) · 743 Bytes
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
import glob
import os
import pandas as pd
os.chdir('/home/anu/Downloads/')
list_files = sorted(glob.glob('/home/anu/Downloads/1JN/**/*.md'))
txt = []
book = []
verse = []
chapter = []
# list files contains all files with .md and their path
for files in list_files:
file = open(files, 'r')
reader = file.readlines()
book.append(files[-12:-9])
verse.append(files[-5:-3])
chapter.append(files[-8:-6])
for line in reader:
content = ''.join(reader).replace('#','•')
txt.append(content)
data = {'Book': book,
'Notes': txt,
'Verses': verse,
'Chapter': chapter}
df = pd.DataFrame(data, columns=['Book', 'Chapter', 'Verses', 'Notes'])
df.to_excel(book[1]+'.xlsx', index=None)
file.close()