Brand new to Groovy and Java.
I have a large, tab delimited text file.
I need to be able 'test' each line of the text file to make sure certain columns have correct data.
For example,
column 2 should only have the term 'New Customer'
column 14 should only have the term 'Dog' or 'Cat'
If any compare fails, then print the incorrect term.
package TestImport
import java.io.BufferedReader;
import java.io.FileReader;
public class PreValidateData {
public static void main(String args[]) throws Exception {
String dataFileName = "C:/Users/BigDaddy/Desktop/test.csv"
BufferedReader bReader = new BufferedReader(new FileReader(dataFileName));
String line;
while (line = bReader.readLine()) {
//Not sure what to put here. This doesn't work
String datavalue[] = line.split("\t");
String value2 = datavalue[1];
String value14 = datavalue[13];
if(value2 != "New Customer"){
Println("FAILURE: line:" + value2.linenumber + "in column 2 is not New Customer. but = " + datavalue[2])
}
if(value14 != "Ndog" or "cat){
Println("FAILURE: line:" + value14.linenumber + "in column 14 is not cat or dog. but = " + term)
}
}
bReader.close();
}
}
I'm not sure where to even begin. Any suggestions?