在这里输入代码
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
<groovy>
newFile("C://RxBen//exports//Control_Exception__c_Exportupdated.csv").withWriter {
new File("C://RxBen//exports//Control_Exception__c_Export.csv").splitEachLine(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*\$)") { ID, Don_t_Work__c,Forwarding_fax_number__c, No_Go__c ->
it.println "${ID},${Forwarding_fax_number__c}AAA,${s}"
}
}
</groovy>
答案 0 :(得分:0)
您可以在参数为2的列中使用字符串上的子字符串,这将从目标字符串中的第三个字符到字符串末尾的所有字符。
示例:
def s = "AATestString"
def newString = s.substring(2)
assert newString == "TestString"
答案 1 :(得分:0)
<强>更新强>
试试这个代码:Ozsaffer接近......
@Grab('com.xlson.groovycsv:groovycsv:1.1')
import static com.xlson.groovycsv.CsvParser.parseCsv
df = new FileReader('filename.csv')
def data = parseCsv(df, readFirstLine: false)
for (def row : data){
println row.values[0].substring(2) //row.values[0] means first column
}