469,366 Members | 2,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

Writing table contents into a Text file

Hi All,
I have stored contents of a table as a variable as shown below:
partner_table = get_table("//table.1.1")

Now i need to write the contents of "partner_table" into a TEXT file.
There is should be some way, does it require file.open command!!

Hoping to hear from you soon.

Cheers
ideal
Jan 21 '08 #1
3 7760
improvcornartist
303 Expert 100+
Something like the following should work for you.
Expand|Select|Wrap|Line Numbers
  1. # Create new file called 'filename.txt' at a specified path.
  2. my_file = File.new("path/filename.txt","w")
  3. # Write text to the file.
  4. my_file.write "text to be written to file"
  5. # Close the file.
  6. my_file.close
Jan 21 '08 #2
Thanks for Code, it works fine :)
I have one more stuff to go with writing the text files,
My present output looks like this:

Upload Result\n filename status #Rows Quantity #Ignored #Deleted #Modified Messages FISCAL-CALENDAR.xls Loaded 140 0 0 0 0 On Hold 0 0 0 0 0

I rather like to see new line after each sentence, what should i do for that? Is there a way i can say to insert new line character after each sentence!
something like this-

Upload Result
filename status
#Rows Quantity
#Ignored

Cheers
Jan 22 '08 #3
improvcornartist
303 Expert 100+
Use "\n" for a new line. Make sure its in double quotes, not single quotes. Using double quotes will output a new line, using single quotes will output the text \n.
Expand|Select|Wrap|Line Numbers
  1. my_file.write @table_cell.to_s + "\n"
Jan 22 '08 #4

Post your reply

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

Similar topics

5 posts views Thread by Robert Gale | last post: by
2 posts views Thread by melanieab | last post: by
2 posts views Thread by Kenneth P | last post: by
16 posts views Thread by iwdu15 | last post: by
6 posts views Thread by dast | last post: by
5 posts views Thread by grinder | last post: by
16 posts views Thread by Claudio Grondi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.