Python CSV 数据提取:获取指定列数据为数组
import csv
定义数据文件路径
file_path = 'C:\Users\Una\Desktop\BatteryMonitor1_modified.csv'
定义结果数组
result = []
打开数据文件
with open(file_path, 'r') as file: # 创建CSV读取器 csv_reader = csv.DictReader(file)
# 遍历每一行数据
for row in csv_reader:
# 将Variation列的数据添加到结果数组
result.append(row['Variation'])
打印结果数组
print(result)
原文地址: https://www.cveoy.top/t/topic/g5SO 著作权归作者所有。请勿转载和采集!