I am using apache commons csvto read contents from a CSV file I get from google trends downloaded as a csv in related query section bottom right. A small subset of the file:
Category: All categories
"bluetooth speakers: (1/1/04 - 8/15/16, Worldwide)"
TOP
speaker,100
bluetooth speaker,100
RISING
portable speakers bluetooth,Breakout
portable speakers,Breakout
My code to read from the file:
private void readCsv(String inputFilePath) {
try {
Reader in = new FileReader(inputFilePath);
Iterable<CSVRecord> records = CSVFormat.RFC4180.withFirstRecordAsHeader().parse(in);
for (CSVRecord record : records) {
String topic = record.get(0);
if (topic != null && !topic.isEmpty()) {
System.out.println(topic);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
The output:
bluetooth speakers: (1/1/04 - 8/15/16, Worldwide)
TOP
speaker
bluetooth speaker
RISING
portable speakers bluetooth
portable speakers
Desired Output:
speaker
bluetooth speaker
portable speakers bluetooth
portable speakers
Based on the data from google(without headers) and the two Headers TOP and RISING I am unable to extract the desired values. Is there any configuration for filtering I can apply to get the desired values?