Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How would I dump the contents of a table to text?  RSS feed

 
James Beeson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once I have connected to a database and selected the appropriate data from a table into a ResultSet, I need to dump that data to text in such a way that I can open it in Excel or import it into a database. The problem I have run into is that wierd characters are mixed in with the output to text that I am currently generating. How do I export data to text so that something like Excel could import it?
------------------
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What weird chracters? One way is to choice a charater that isn't in the data from the database and use it for a delimiter. One I commonly use is ~. If this doesn't do it, give us an example of the wird text.
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
I wrote a generic program that would take the name of the table I wanted to dump and wrote each column to a flat file with a "|" as my delimiter.
The gist of the program used the metadata object pretty heavily. I just chose "|", because it was easy to see for me. You can also use Carl's suggestion and use "~".
The important thing is to make sure you pick a character that doesn't appear in your own data.
-Peter
 
James Beeson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the idea, but I need to find some code examples. I have been doing Java programming for a while but it's been almost exclusively Swing & JDBC stuff. I am not very good at I/O yet. Where could I find examples of a program that does what you are talking about. I am really hurting for time. Thanks!
James
jsbeeson4@hotmail.com
Originally posted by Peter Tran:
James,
I wrote a generic program that would take the name of the table I wanted to dump and wrote each column to a flat file with a "|" as my delimiter.
The gist of the program used the metadata object pretty heavily. I just chose "|", because it was easy to see for me. You can also use Carl's suggestion and use "~".
The important thing is to make sure you pick a character that doesn't appear in your own data.
-Peter


------------------
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the code to do what you want:

[This message has been edited by Peter Tran (edited January 18, 2001).]
 
James Beeson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you VERY, VERY much!!
James

------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!