【问题】
I just started with Python 3.4.2 and trying to find and replace text in csv file.
In Details,Input.csvfile contain below line:
0,0,0,13,.\New\_Path-1.1.12\Impl\Appli\Library\Module_RM\Code\src\Exception.cpp 0,0,0,98,.\Old_Path-1.1.12\Impl\Appli\Library\Prof_bus\Code\src\Wrapper.cpp 0,0,0,26,.\New_Path-1.1.12\Impl\Support\Custom\Vital\Code\src\Interface.cpp 0,0,0,114,.\Old_Path-1.1.12\Impl\Support\Custom\Cust\Code\src\Config.cpp
I maintained my strings to be searched in other file namedlist.csv
Module_RM Prof_bus Vital Cust
Now I need to go through each line ofInput.csvand replace the last column with the matched string.
So my end result should be like this:
0,0,0,13,Module_RM 0,0,0,98,Prof_bus 0,0,0,26,Vital 0,0,0,114,Cust
I read the input files first line as a list. So text which i need to replace came inline[4]. I am reading each module name in thelist.csvfile and checking
使用Python和集算器替换CSV文件中的文本

初学者尝试使用Python 3.4.2查找并替换CSV文件中的文本,目标是遍历Input.csv的每一行,将最后一列的文本替换为list.csv中匹配的字符串。最终通过集算器的SPL脚本实现无需循环的文本结构化计算,完成文件内容更新。
最低0.47元/天 解锁文章
686





