473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Parsing

73
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.......
May 8 '07 #1
11 1625
r035198x
13,262 8TB
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.......
Depends 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?
May 8 '07 #2
jyohere
73
Depends 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?
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......

i.e ...the file looks like

Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164501 Job123456789123456789123456789123456Note Circuit12345123456789123456789123456Name 5 10 20

Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164502 Job123456789123456789123456789123456Note Circuit12345123456789123456789123456Name 5 10 20

20070508164501 is the date...i want the entries between 20070508164500 and
20070508164515
May 8 '07 #3
r035198x
13,262 8TB
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......

i.e ...the file looks like

Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164501 Job123456789123456789123456789123456Note Circuit12345123456789123456789123456Name 5 10 20

Cid Ctype 2 PortID j k l m EntytyType 0 0 0 20070508164502 Job123456789123456789123456789123456Note Circuit12345123456789123456789123456Name 5 10 20

20070508164501 is the date...i want the entries between 20070508164500 and
20070508164515
Have a look at this and see what you can get out of it. Post if you need more help.
May 8 '07 #4
jyohere
73
Have a look at this and see what you can get out of it. Post if you need more help.
It is not of much help......So pls help
May 8 '07 #5
r035198x
13,262 8TB
It is not of much help......So pls help
That'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.
May 8 '07 #6
jyohere
73
That'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.
I 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 dates
May 8 '07 #7
r035198x
13,262 8TB
I 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 dates
Are you able to read a file line by line say into an array?
May 8 '07 #8
jyohere
73
Are you able to read a file line by line say into an array?
There 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
May 8 '07 #9
r035198x
13,262 8TB
There 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
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.

Now do you know that you can split a string into a String array using the split method? e.g
Expand|Select|Wrap|Line Numbers
  1.  String s = "This string"; 
  2. String[] items = s.split(" ");
  3.  
May 8 '07 #10
jyohere
73
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.

Now do you know that you can split a string into a String array using the split method? e.g
Expand|Select|Wrap|Line Numbers
  1.  String s = "This string"; 
  2. String[] items = s.split(" ");
  3.  
what u said can be done only for one line....wat if i have muliple lines and i do not know the number of lines
May 8 '07 #11
r035198x
13,262 8TB
what u said can be done only for one line....wat if i have muliple lines and i do not know the number of lines
Like has been shown in the link I gave you, you can read a whole file using a loop structured as
Expand|Select|Wrap|Line Numbers
  1.  while((line = input.readLine()) != null) { 
  2.  
  3. }
  4.  
Where do you want to extract the records to?
May 8 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
7
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.