aspose file tools*
The moose likes Beginning Java and the fly likes Parse text file and query dabase and email missingList as CSV file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parse text file and query dabase and email missingList as CSV file" Watch "Parse text file and query dabase and email missingList as CSV file" New topic
Author

Parse text file and query dabase and email missingList as CSV file

sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 282
I have a pipe(|) separated text file with many rows of data. I need to parse the text file and generate a query and query database and see which records are not there in database( each row of the text field corresponds to each record in database). Then I need to prepare missing List CSV file and email the user about the missing list values. I am treating whole text file as array object and individual rows as again small arrays with many values(could be string, numericals etc) separated by | symbol.
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11477
    
  16

My general suggestions are always the same:

Separate your tasks into the individual components. Reading a file is a distinct task from querying the database. Parsing a string is a distinct task from building a query.

Only work on one task at a time. Test it over and over and over and make sure it works before doing the next task.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 282
thank you.

http://www.velocityreviews.com/forums/t390377-using-scanner-with-a-bar-delimiter.html

I checked above link.

It is separating at |.

Now I need to get first two strings and form a query with those first 2 stings to run againest the oracle database.

Then generate missing list CSV report(with those first two strings) if those records not present in oracle databse and email the the user missing CSV file(i have the emailing part code also with me).

I am not sure on how to do following things


>>
Now I need to get first two strings and form a query with those first 2 stings to run againest the oracle database.

>>
Then generate missing list CSV report(with those first two strings) if those records not present in oracle databse

Please advise
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11477
    
  16

This:
Now I need to get first two strings and form a query with those first 2 stings to run againest the oracle database.

is at LEAST three things:
1) Get the first two strings
2) Form a query from two strings
3) Run a query against a database.

Focus on one at a time.
 
Consider Paul's rocket mass heater.
 
subject: Parse text file and query dabase and email missingList as CSV file