forked from aolofsson/awesome-semiconductor-startups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
51 lines (42 loc) · 1.75 KB
/
update.py
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
42
43
44
45
46
47
48
49
50
51
#1. Read startups and alumni csv into lists
#2. Read in README line by line and
#3. Insert formatted tables after reference to csv
import os
import csv
import re
def main():
# Read in CSV files
startups = list(csv.DictReader(open("startups.csv", "r"), delimiter=","))
alumni = list(csv.DictReader(open("alumni.csv", "r"), delimiter=","))
# Read in README
with open('header.md') as f:
header = f.read().splitlines()
# Insert csv lists
with open('README.md', 'w') as f:
################################
# Printing out old README header
################################
for line in header:
print(line, file=f)
################################
# Printing out all startups
################################
print("\n## Startups", file=f)
print("\n| Company | Technology | Founded | Country | Description |", file=f)
print("|---------|------------|---------|---------|-------------|", file=f)
for x in startups:
print(f"|[{x['Company']}](https://{x['Website']}) | {x['Technology']} | {x['Founded']} | {x['Country']} |{x['Description']} |", file=f)
################################
# Printing out exits
################################
print("\n## Alumni", file=f)
print("\n| Company | Exit | Year | Value | Link |", file=f)
print("|---------| ------- | ------ | ------|------|", file=f)
for x in alumni:
if not re.search(r'http', x['Link']):
link = "NA"
else:
link = f"[Source]({x['Link']})"
print(f"|{x['Company']} | {x['Exit']} | {x['Year']} | {x['Value']} | {link} |", file=f)
if __name__ == '__main__':
main()