-
Notifications
You must be signed in to change notification settings - Fork 29
/
README.Rmd
200 lines (146 loc) Β· 5.22 KB
/
README.Rmd
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(reticulate)
```
# Awesome PyLadies' Repository
<!-- badges: start -->
[![Awesome](https://awesome.re/badge.svg)](https://awesome.re)
<!-- badges: end -->
## What Is This Repository About?
It provides a curated list of awesome content by PyLadies and also seeks to collect information to further promote content by awesome [PyLadies on Mastodon](https://botsin.space/@pyladies_bot) π€
To contribute to the list, please see the [contributing](CONTRIBUTING.md) guidelines β¨
## List of Content
<!-- Created by accessing the json files in [blogs/](blogs/).-->
### List of Contributors as Tiles
```{python, echo=FALSE, eval=FALSE, results='asis'}
# TODO: Make it more beautiful
import pandas as pd
import json
import os
directory_path = "blogs/"
# Create an empty list to store the loaded JSON data
json_data = []
# Loop through each file in the directory
for filename in os.listdir(directory_path):
# Check if the file is a JSON file
if filename.endswith(".json"):
# Open the file and load the JSON data
with open(directory_path + filename, "r") as json_file:
data = json.load(json_file)
json_data.append(data)
json_data.sort(key=lambda x: x["title"])
def split(lst,n):
print(lst[i::n])
return [lst[i::n] for i in range(n)]
# Split data into three chunks
data_splitted = list(split(json_data, 3))
# Parse data
def parse_data(data_splitted, i):
grid_entries = []
for entry in data_splitted[i]:
name = entry['authors'][0]['name']
photo_url = entry['photo_url']
title = entry['title']
blog_url = entry['url']
grid_entry = f'<a href="{blog_url}"><img width="100" alt="Image of {name}" src="{photo_url}"><br/></a><span class="caption">{name}</span>'
grid_entries.append(grid_entry)
# Append to column if there's a different length
length_longest_split = len(data_splitted[0])
length_split = len(data_splitted[i])
if length_split < length_longest_split:
missing = length_longest_split - length_split
grid_entries = grid_entries + (missing*[''])
return grid_entries
data = {}
for i in range(len(data_splitted)):
data[f"col_{i}"] = parse_data(data_splitted, i)
df = pd.DataFrame(
data={"col_0": data["col_0"],
"col_1": data["col_1"],
"col_2": data["col_2"]}
)
df.columns = [''] * len(df.columns)
print(df.to_markdown(index=False))
```
```{python, echo = FALSE, results='asis', eval=TRUE}
import json
import os
import pandas as pd
directory_path = "blogs/"
# Create an empty list to store the loaded JSON data
json_data = []
# Loop through each file in the directory
for filename in os.listdir(directory_path):
# Check if the file is a JSON file
if filename.endswith(".json"):
# Open the file and load the JSON data
with open(directory_path + filename, "r") as json_file:
data = json.load(json_file)
json_data.append(data)
json_data.sort(key=lambda x: x['authors'][0]['name'])
header = "| | | |"
first_row = "|:-------------------------:|:-------------------------:|:-------------------------:|"
grid_entries = ""
# Parse data
count = 0
for entry in json_data:
count += 1
name = entry['authors'][0]['name']
photo_url = entry['photo_url']
title = entry['title']
blog_url = entry['url']
if count % 3 == 0:
sep = '\n|'
else:
sep = ''
grid_entry = f'<a href="{blog_url}"><img width="100" alt="Image of {name}" src="{photo_url}"><br></a><span class="caption">{name}</span>|{sep}'
grid_entries += grid_entry
full_table = f"{header}\n{first_row}\n|{grid_entries}"
text = os.linesep.join([s for s in full_table.splitlines() if s])
print(text)
#print(to_be_returned)
```
### List of Content as List
#### Blogs
```{r, echo = FALSE, results='asis'}
json_list <- list.files(here::here("blogs"), "json$", full.names = TRUE)
dt <- lapply(json_list, jsonlite::read_json)
invisible(
lapply(dt, function(x){
if (x$type=="blog") {
cat(sprintf(" - [%s](%s) by %s",
x$title, x$url,
paste(sapply(x$authors, function(x) x$name), collapse=", ")),
sep = "\n")
}
})
)
```
#### YouTube Channels
```{r, echo = FALSE, results='asis'}
json_list <- list.files(here::here("blogs"), "json$", full.names = TRUE)
dt <- lapply(json_list, jsonlite::read_json)
invisible(
lapply(dt, function(x){
if (x$type=="youtube") {
cat(sprintf(" - [%s](%s) by %s",
x$title, x$url,
paste(sapply(x$authors, function(x) x$name), collapse=", ")),
sep = "\n")
}
})
)
```
## Any Open Questions?
If you have any questions or suggestions, please reach out to [Cosima](https://linktr.ee/cosima_meyer) or open an [issue](https://github.com/cosimameyer/awesome-pyladies-blogs/issues/new/choose).
## Credits
This repository relies heavily on the [Awesome R-Ladies blogs repository](https://github.com/rladies/awesome-rladies-blogs), to whom all credit goes.
## License
[![CC0](https://upload.wikimedia.org/wikipedia/commons/6/69/CC0_button.svg)](https://creativecommons.org/publicdomain/zero/1.0/)