Regex 如何使用csv文件仅替换文本文件中的某些字符串

Regex 如何使用csv文件仅替换文本文件中的某些字符串,regex,python-3.x,string,file,replace,Regex,Python 3.x,String,File,Replace,我有一个csv文件(script.csv),用作替换多个文件中字符串的脚本。ase文件是图形文件。csv文件中指定了每个文件的图形数。 对于第一个文件,图形数为1。对于第二个文件-3图,对于第三个文件-2图,对于第四个文件-4图,对于第五个文件-1图。。。。同样地 csv格式的数据(script.csv) 假设x4.txt是一个四图形文件。然后,我使用正则表达式搜索要替换的字符串位置。然后我找到了五个位置要替换,但我只需要替换4个位置。 例如: 如果重新搜索(r'/et y',字符串): 打印(

我有一个csv文件(script.csv),用作替换多个文件中字符串的脚本。ase文件是图形文件。csv文件中指定了每个文件的图形数。 对于第一个文件,图形数为1。对于第二个文件-3图,对于第三个文件-2图,对于第四个文件-4图,对于第五个文件-1图。。。。同样地

csv格式的数据(script.csv)

假设x4.txt是一个四图形文件。然后,我使用正则表达式搜索要替换的字符串位置。然后我找到了五个位置要替换,但我只需要替换4个位置。 例如: 如果重新搜索(r'/et y',字符串): 打印(字符串)

包含要替换的字符串的输入文件:

 /et    y "HHJKLJ" ;axis title

/et    y "SDFSDF"  ;axis title

 /et    y "STSTS" ;axis title

 /et    y "uiuhig"   ;axis title

 /et    y "fgfjhgjhg" ;axis title
我希望我的输出为

 /et    y "y1" ;axis title

 /et    y "y2"  ;axis title

 /et    y "y3" ;axis title

 /et    y "y4"   ;axis title

 /et    y "fgfjhgjhg" ;axis title
但我真正得到的是:

/et    y "y1" ;axis title

/et    y "y2"  ;axis title

/et    y "y3" ;axis title

/et    y "y4"   ;axis title

/et    y "y1" ;axis title


I dont to replace the fifth string in y1 I want only to replace upto fourth, for the fifth string just write what is in the input file. 
如何解决这个问题

 /et    y "y1" ;axis title

 /et    y "y2"  ;axis title

 /et    y "y3" ;axis title

 /et    y "y4"   ;axis title

 /et    y "fgfjhgjhg" ;axis title
/et    y "y1" ;axis title

/et    y "y2"  ;axis title

/et    y "y3" ;axis title

/et    y "y4"   ;axis title

/et    y "y1" ;axis title


I dont to replace the fifth string in y1 I want only to replace upto fourth, for the fifth string just write what is in the input file.