Hi there,
I am trying to parse a CSV file, I have a program which will read in the contents of the file and display them to the console and i need to parse some of the fields, which I have no idea how to do
I am trying to get the field info into to an SWT table. The csv file I'm trying to parse has some useless information before and after the file info which is numbered [0-n].
I need to get each relevent line and take its individual pieces of data and store them in an array or something so I can put them into my table i.e. '0:' in one tableItem and 'bla.jpg' in the next tableItem.
Any help or code samples would be much appreciated,
Thanks in advance,
Shinny
--START OF CSV FILE--
File: penDriveImage3.001
Start: Wed Aug 02 19:49:44 2006
Length: 992 MB (1040187392 bytes)
Num Name (bs=512) Size File Offset Comment
0: 8426.jpg 5 KB 4314525 (null) /*THESE LINES ARE IN ONE FIELD EACH!?!*
1: 13578.jpg 42 KB 6952364 (null)
2: 13663.jpg 27 KB 6995952 (null)
3: 13791.jpg 26 KB 7061467 (null)
4: 14825.jpg 46 KB 7590486 (null)
5: 16830.jpg 83 KB 8617069 (null)
6: 16999.jpg 36 KB 8703995 (null)
...RANDOM DATA HERE...
--END OF CSV FILE--
Code:
package GUI;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadSource
{
public static void main(String[] arguments)
{
try
{
FileReader file = new FileReader("C:\\audit.csv");
BufferedReader buff = new BufferedReader(file);
boolean eof = false;
while(!eof){
String line = buff.readLine();
if(line == null)
eof = true;
else
System.out.println(line);
}
buff.close();
}
catch(IOException e)
{
System.out.println("Error -- " + e.toString());
}
}
}