[英]How to split contents of column into different columns in csv files using python?
[英]Split single column in csv files using python
這是CSV文件中一列中的數據。
91.1 [69.6-118.8]
93.9 [74.5-118.3]
96.7 [79.1-118.2]
99.5 [83.8-118.5]
102.3 [88.1-119.3]
105.0 [92.0-120.6]
我需要做的是將其分為兩列。
91.1 [69.6-118.8]
93.9 [74.5-118.3]
96.7 [79.1-118.2]
99.5 [83.8-118.5]
102.3 [88.1-119.3]
105.0 [92.0-120.6]
最簡單的方法是使用open.readlines()
和str.split()
arr =[]
lines = open("my.csv").readlines()
for line in lines:
arr.append(line.split())
print(arr)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.