这是我的csv文件:
CommitId RefactoringType RefactoringDetail
d38f7b334856ed4007fb3ec0f8a5f7499ee2f2b8 Pull Up Attribute "Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
d38f7b334856ed4007fb3ec0f8a5f7499ee2f2b8 Pull Up Attribute "Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
d38f7b334856ed4007fb3ec0f8a5f7499ee2f2b8 Pull Up Attribute "Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Pla
我需要提取这个:
RefactoringDetail
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
我试过这个代码:
import pandas as pd
df = pd.read_csv('result_refactorings.csv', sep='delimiter', header=None)
df.iloc[:,-1]
它返回所有的数据
请帮忙!你知道吗
Pandas对于处理csv文件非常有用,您只需要以下代码就可以读取csv并将整个列保存到一个变量中:
编辑:提供的文件中的分隔符是
;
,而不是默认的,
。你知道吗如果您只想使用内置的csv模块:
这段代码打印出第三列,并将第三列中的每一项添加到一个列表
third_column
。。根据你想做的,去掉一个或另一个。你知道吗编辑:仔细观察,你的csv输入似乎是用不均匀的空格分隔的。。实际上不是标签,这就是它看起来的样子。。添加了一个小正则表达式,用一个实际的制表符替换2个或更多的并发空格。。因为在当前状态下,它不是有效的csv。你知道吗
相关问题 更多 >
编程相关推荐