-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhichCountriesExport.java
More file actions
31 lines (29 loc) · 952 Bytes
/
Copy pathWhichCountriesExport.java
File metadata and controls
31 lines (29 loc) · 952 Bytes
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
30
31
package CSVPractice;
import edu.duke.*;
import org.apache.commons.csv.*;
/**
* Write a description of WhichCountriesExport here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class WhichCountriesExport {
public void listExporters(CSVParser parser, String exportOfInterest) {
//for each row in the CSV file
for(CSVRecord record: parser) {
//look at the exports column
String export = record.get("Exports");
//check is it contains exportOfInterest
if(export.contains(exportOfInterest)) {
//if so write the country down.
String country = record.get("Country");
System.out.println(country);
}
}
}
public void whoExportsCoffee() {
FileResource fr = new FileResource();
CSVParser parser = fr.getCSVParser();
listExporters(parser, "coffee");
}
}