项目初次提交
This commit is contained in:
21
utils/csv_utils.py
Normal file
21
utils/csv_utils.py
Normal file
@ -0,0 +1,21 @@
|
||||
import csv
|
||||
|
||||
|
||||
def read_csv(file_path):
|
||||
"""
|
||||
根据文件路径读取csv文件
|
||||
:param file_path:
|
||||
:return:
|
||||
"""
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
# 创建 CSV 阅读器对象
|
||||
csv_reader = csv.reader(file)
|
||||
# 跳过标题行
|
||||
next(csv_reader)
|
||||
result_row = []
|
||||
for row in csv_reader:
|
||||
if row is None:
|
||||
break
|
||||
result_row.append(row)
|
||||
return result_row
|
||||
return None
|
Reference in New Issue
Block a user