I have a text file containing lot of data organised in a manner......i want to know which is the efficient way in java to parse such a file.......
Parsing
Collapse
X
-
Depends on the manner in which the data is organised and the reason for parsing the file.Originally posted by jyohereI have a text file containing lot of data organised in a manner......i want to know which is the efficient way in java to parse such a file.......
Do you want to extract certain fields from it or do you want to search for certain patterns e.t.c? -
The text file is organised as space separated fields....there are many entries .....for example, i have a date field along with all other fields...i want to get the entries which are between a range of dates in the file......Originally posted by r035198xDepends on the manner in which the data is organised and the reason for parsing the file.
Do you want to extract certain fields from it or do you want to search for certain patterns e.t.c?
i.e ...the file looks like
Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164501 Job123456789123 456789123456789 123456Note Circuit12345123 456789123456789 123456Name 5 10 20
Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164502 Job123456789123 456789123456789 123456Note Circuit12345123 456789123456789 123456Name 5 10 20
20070508164501 is the date...i want the entries between 20070508164500 and
20070508164515Comment
-
Have a look at this and see what you can get out of it. Post if you need more help.Originally posted by jyohereThe text file is organised as space separated fields....there are many entries .....for example, i have a date field along with all other fields...i want to get the entries which are between a range of dates in the file......
i.e ...the file looks like
Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164501 Job123456789123 456789123456789 123456Note Circuit12345123 456789123456789 123456Name 5 10 20
Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164502 Job123456789123 456789123456789 123456Note Circuit12345123 456789123456789 123456Name 5 10 20
20070508164501 is the date...i want the entries between 20070508164500 and
20070508164515Comment
-
I want to read on a field by field basis sayOriginally posted by r035198xThat's unfortunate because that's as much as I was going to post here anyway.
I 'don't see how it fails to help you though since it talks about reading a file which is what you want to do.
Name Age DateOfBirth
Jyo 25 28-11-82
Ram 30 20-12-81
say I want to read the above file and find out the entries whose DOB is between two given datesComment
-
Are you able to read a file line by line say into an array?Originally posted by jyohereI want to read on a field by field basis say
Name Age DateOfBirth
Jyo 25 28-11-82
Ram 30 20-12-81
say I want to read the above file and find out the entries whose DOB is between two given datesComment
-
Well you don't have to read it into an array. I just wanted to make sure you are able to read data from a textfile.Originally posted by jyohereThere is a problem in that too.....the number of rows is not known.....it gets changed dynamically.... .so i cannot fix the size if i use a 2d array
Now do you know that you can split a string into a String array using the split method? e.g
Code:String s = "This string"; String[] items = s.split(" ");Comment
-
what u said can be done only for one line....wat if i have muliple lines and i do not know the number of linesOriginally posted by r035198xWell you don't have to read it into an array. I just wanted to make sure you are able to read data from a textfile.
Now do you know that you can split a string into a String array using the split method? e.g
Code:String s = "This string"; String[] items = s.split(" ");Comment
-
Like has been shown in the link I gave you, you can read a whole file using a loop structured asOriginally posted by jyoherewhat u said can be done only for one line....wat if i have muliple lines and i do not know the number of lines
Where do you want to extract the records to?Code:while((line = input.readLine()) != null) { }Comment
Comment