从CSV复制时,我有一个类似CSV所用状态的字段?

时间:2017-04-05 17:11:04

标签: postgresql

我知道基本命令是WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.get("https://login.yahoo.com/"); driver.findElement(By.xpath("//input[@id='login-username']")).sendKeys("Username"); driver.findElement(By.xpath("//*[@id='login-signin']")).click(); WebDriverWait wait = new WebDriverWait(driver,20); wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='login-passwd']"))); driver.findElement(By.xpath("//*[@id='login-passwd']")).sendKeys("Password"); 我想要做的是添加" WA"到此txt文件的每一行的State字段。

1 个答案:

答案 0 :(得分:0)

我的建议是使用状态字段数据预处理输入文件。一种简单的方法是将awk OFS(输出字段分隔符)设置为tab,如下所示:

# Assuming the 5th field of the input file is the state field
awk '{OFS = "\t"; $5 = "WA"; print}' input.txt > inputStateRevised.txt

如果现有输入文件中没有state字段,可以按如下方式附加state字段:

# Assuming there are a total of 8 fields in the original input file
awk '{OFS = "\t"; $9 = "WA"; print}' input.txt > inputStateAppended.txt