From 4b6234985cd75deb83f438217e596aaf333475f8 Mon Sep 17 00:00:00 2001 From: AllenWrong <884691896@qq.com> Date: Sun, 28 Apr 2024 19:28:41 +0800 Subject: [PATCH] upload: add jsonl_to_df --- data_io.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 data_io.py diff --git a/data_io.py b/data_io.py new file mode 100644 index 0000000..b242c23 --- /dev/null +++ b/data_io.py @@ -0,0 +1,10 @@ +import json +import pandas as pd + + +def jsonl_to_df(file_path: str) -> pd.DataFrame: + data = [] + with open(file_path, 'r', encoding='utf-8') as file: + for line in file: + data.append(json.loads(line)) + return pd.DataFrame(data)