Created
August 16, 2018 13:23
-
-
Save iamsibasish/0a51b6d8957091a35f1809ec6bccff01 to your computer and use it in GitHub Desktop.
CSVParser created by sibasishmohanty - https://repl.it/@sibasishmohanty/CSVParser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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