Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Ok here is my scenario, i receive these documents in excel files they have users first and last name, badge number, email, E.T.C. Now i want to extract just the badge number out of this excel document. So my first question is i want to do this with a java program so what do i want to research about to make a java program that searches one of these excel documents and assuming it is space dillimeted pulls just the badge number out?
Then i have another document called NCAS, this document has every employee listed only unique thing here is badge number and username but i want to take the badge number out of the first document and use this badge number to search my NCAS document. This will bring up a line in the document with user badge number username phone , e.t.c. again this document is space dillemited. So i want it to pull a field out of this document which i believe is the first one copy it.
Then for my third thing i want to transfer this copied username over to a esb (oracle product) which has a database adapter on it and use it to input this username and query through our oracle database that username after that im going to use esb database connector to assign users responsibilities. but thats another project im just trying to extract certain information from certain documents i will worry about insserting this into a database laterLearning in progress..........

I think you may find the StringTokenizer class useful.
I assume the NCAS document is a text file. If it is not too large (compared with amount of RAM available), then you may consider reading the whole document in, tokenizing, and storing it in a Map. This will make it trivial to look up the badge number. If it is too large, you could still create a map keyed on badge number, but instead of storing the data, store the file offset. If the document is already sorted, then you can just do a binary search directly in the document. You'll need to look up the methods in the Java API reference manual.
As for your third thing, let's do one at a time.

Ok you lose me with StringTokenizer as for doing one at a time i agree with you is StringTokenizer a function of java? and when you say store in memory .............. as for this ncas document i speak of it is 2.23 Mb big with 11 different subjects in there ex.
badge # | first name | lastname | mailzone | E.T.C.The pipes | arent in the document i was trying to be neat this document is dillimited by spaces or i believe they are called white spaces.
Yes one at a time if you could help me or direct me towards what i want to look into to read off an excel document (badge # to be specific) and then be able to go read this NCAS and query the badge number pulled from excel document. Just point me to where i want to start off i mean in the mean time i will go review the java api and try to find something to help me out here
Learning in progress..........
Sorry back to you saying store in memory i have 2 GB but we might put this out on a unix server running solaris or something to that nture.
When you say store in memory as opposed to what ?

java.util.StringTokenizer is a Java class that is part of the standard Java API. This will help you to break each line up into a number of smaller strings. For the details, you need to look it up in the API Reference.
A 2 MB file is not that large by today's standards and most modern PCs or Unix boxes should have enough memory to read the whole file in, line by line, and construct a map (such as a HashMap - again, look it up in the API Reference). You can then use that map to look up the badge number and get all the information stored for that badge number. Sorry I can't be too specific or give you source code, but this is not a simple question, it's a whole project and it will require you to do a lot of research. I'm just trying to save you a little time by pointing you in the right direction so you know which bits of Java you need to read about.

I understand this is a large project especially if i got it working that would be great :) I appreciate your help also
This also is only 50% of the project :) want me to tell you what i would like to do with the extracted data :)
Learning in progress..........

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |