Skip to content

Instantly share code, notes, and snippets.

@iamsibasish
Created August 16, 2018 13:23
Show Gist options
  • Save iamsibasish/f4da8c949e004842347ff132e3aa3f0c to your computer and use it in GitHub Desktop.
Save iamsibasish/f4da8c949e004842347ff132e3aa3f0c to your computer and use it in GitHub Desktop.
CSVParser created by sibasishmohanty - https://repl.it/@sibasishmohanty/CSVParser
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
// Source of file
String csvFile = "/Users/srikanth/Downloads/C2ImportGroupsSample.csv";
BufferedReader br = null;
String line = "";
String cvsSplitBy = ",";
try {
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
// use comma as separator
String[] fileds = line.split(cvsSplitBy);
//let assume the id present at 3rd index
//let the id to which u want to pass the id
actionOnid(fileds[3]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void actionOnid(String id) {
System.out.println("Use the id-"+id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment