-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadCSV.java
29 lines (21 loc) · 835 Bytes
/
ReadCSV.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import com.csvreader.CsvReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
public class ReadCSV {
public static void main(String[] args) throws Exception {
String filepath = "/Users/gaozheng/shutian/compound_terms.tsv";
ArrayList<String[]> csvlist = readByCsvReader(filepath);
for (String[] strings : csvlist) {
System.out.println(strings[0] + " " + strings[1]);
}
}
public static ArrayList<String[]> readByCsvReader(String filePath) throws Exception {
CsvReader csvReader = new CsvReader(filePath, '\t', Charset.defaultCharset());
ArrayList<String[]> arrList = new ArrayList<>();
while(csvReader.readRecord()){
arrList.add(csvReader.getValues());
}
csvReader.close();
return arrList;
}
}