heziiiii commited on
Commit
3a5e1dc
·
verified ·
1 Parent(s): 3e0b60e

Upload read_danbooru_wiki_parquet.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. read_danbooru_wiki_parquet.py +38 -0
read_danbooru_wiki_parquet.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas as pd
3
+ import time
4
+ import json
5
+
6
+ import random
7
+ import dateutil.parser
8
+
9
+
10
+ #read parquet file
11
+
12
+ df = pd.read_parquet("/mnt/data/danbooru-wiki-2024/data/train-00000-of-00001.parquet")
13
+
14
+ print(df.columns)
15
+
16
+ print(df.head())
17
+
18
+ #print first 5 rows
19
+ print(df.head(5))
20
+
21
+
22
+ #to_dict
23
+ df_dict = df.to_dict(orient='records')
24
+
25
+ print(df_dict[0])
26
+ # "{'id': 115416, 'created_at': '2020-08-08T19:16:56.966+09:00', 'updated_at': '2023-01-03T01:14:39.307+09:00', 'title': 'veemusic', 'other_names': array([], dtype=object), 'body': '[[Virtual YouTuber]] agency and music label launched in November 2018 by [[Virtual Gorilla]], who acts as its virtual president. Its members include individual and group-oriented VTubers.\r\n\r\nh4. Members\r\n\r\n* [[Virtual Gorilla]]\r\n* [[Hosaki Menma]] (left February 2020)\r\n* [[Inui Shin\'ichirou]]\r\n* [[Chikuwa (vtuber)|]] (retired)\r\n\r\nh4. External links\r\n\r\n* "Offical Website":http://veemusic.jp/\r\n* "YouTube":https://www.youtube.com/@veemusic3056\r\n* "Twitter":https://twitter.com/VEEM_Official', 'is_locked': False, 'is_deleted': False, 'category': 'copyright', 'tag': 'veemusic'}
27
+ # (naifu) root@iv-ydj8v22akgqbxys13oit:/mnt/data# "
28
+
29
+ # arrat to list
30
+ for i in range(len(df_dict)):
31
+ df_dict[i]['other_names'] = df_dict[i]['other_names'].tolist() #
32
+
33
+ print(df_dict[0])
34
+
35
+ # save to json
36
+ with open('/mnt/data/danbooru-wiki-2024/data/train-00000-of-00001.json', 'w') as f:
37
+ json.dump(df_dict, f)
38
+