Code:
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Scanner;
public class dataReader {
@SuppressWarnings("rawtypes")
public static void main(String[] args) throws Exception {
String splitBy =",";
BufferedReader br = new BufferedReader(new FileReader("C:/practice/testData.csv"));
String line = br.readLine();
int counter = 0;
while ((line = br.readLine()) != null){
counter++;
String[] b = line.split(splitBy);
for (int x = 0; x < b.length; x++){
System.out.println(b[x]);
}
}
System.out.println(counter);
br.close();
}
}
When I run it, it goes through the CSV and displays some output but it starts with product ID 4000+. It basically only outputs results for the last thousand rows in the CSV. I'm wrangling with a really ugly CSV file to try to get some useful data out of it so that I can write all of it into a new database later on. I'd appreciate any tips.
As in the comments, the issue is that System.out.println prints to your console. The console will have a limit to the number of lines it can display, which is why you see the last ~1000 lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With