-7

I have a csv file and suppose I want to read file
from line number say 14 till line number 30
How this can be achieved?

Thanks,

Pankaj Tiwari
  • 71
  • 2
  • 8
  • Read it like how you read an excel file – Kasnady Jun 19 '13 at 06:10
  • Have you even google it ?. http://stackoverflow.com/questions/2312756/in-java-how-to-read-from-a-file-a-specific-line-given-the-line-number – Yahya Arshad Jun 19 '13 at 06:13
  • Yes,I have google it but not find any specific answers – Pankaj Tiwari Jun 19 '13 at 06:17
  • interesting. just wrote a stateful csv parser that could do that. well in c# that is – Marco Forberg Jun 19 '13 at 06:44
  • CSVReader can be used for reading a CSV file starting from some line. The fourth argument of CSVReader can be used to skip lines, so if you want to start processing the CSV file from the nth line, you can pass (n-1) as the last argument and then process it upto the required line number. – BajajG Sep 18 '15 at 05:02

3 Answers3

3

have you tried this:

FileInputStream fs= new FileInputStream("someFile.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fs));
for(int i = 0; i < 14; ++i)
  br.readLine();
String lineIWant = br.readLine();
Supericy
  • 5,866
  • 1
  • 21
  • 25
The Badak
  • 2,010
  • 2
  • 16
  • 28
0

Use any of CSV libraries, such as CSV Java or CSV Reader.

http://sourceforge.net/projects/javacsv/

http://www.csvreader.com/java_csv.php

Martin Strejc
  • 4,307
  • 2
  • 23
  • 38
0

You should use jxl library. You can find it at http://jexcelapi.sourceforge.net/. I use it in my project and it is really helpful.

Marek
  • 3,935
  • 10
  • 46
  • 70