Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
LLM_extraction
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李盟
LLM_extraction
Commits
02226617
Commit
02226617
authored
Mar 04, 2025
by
李盟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
f9515dfa
Pipeline
#505
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
json2excel.py
json2excel.py
+33
-0
No files found.
json2excel.py
0 → 100644
View file @
02226617
import
os
import
re
import
json
import
pandas
as
pd
file_list
=
os
.
listdir
(
"/home/limeng/NLP/LLM/code/0220/result"
)
files_sorted
=
sorted
(
file_list
,
key
=
lambda
x
:
int
(
re
.
search
(
r'(\d+)'
,
x
)
.
group
()))
json_folder_path
=
"/home/limeng/NLP/LLM/code/0220/result"
for
filename
in
files_sorted
:
# 读取 JSON 文件
file_path
=
os
.
path
.
join
(
json_folder_path
,
filename
)
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
data
=
json
.
load
(
file
)
# 提取 extracted_info 字段
extracted_info
=
data
.
get
(
"extracted_info"
,
{})
# 创建一个字典用于存储这条数据
row_data
=
{}
# 遍历 extracted_info 中的键值对,填充到字典中
for
key
,
value
in
extracted_info
.
items
():
row_data
[
key
]
=
value
for
column
in
df
.
columns
:
if
column
not
in
row_data
:
row_data
[
column
]
=
"无"
# 将 row_data 添加到 DataFrame 中
new_row
=
pd
.
DataFrame
([
row_data
])
df
=
pd
.
concat
([
df
,
new_row
],
ignore_index
=
True
)
# 输出结果 DataFrame
print
(
df
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment