473,320 Members | 2,202 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,320 software developers and data experts.

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 8030
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

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

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
5
by: Robert Gale | last post by:
I am writing an RSS reader in C# and I'm trying to write the contents of a TreeView to an XML file. I have tried using XmlWriter and have managed to write simple tree structures but I get confused...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
2
by: Kenneth P | last post by:
Hi, I'm developing asp.net (vb) apps in VS.NET 2003, and I'd like to know how you can write style sheet code in a sub in an .aspx page that when it's rendered as html/text/css code in the .aspx...
16
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
6
by: dast | last post by:
Hello, I’m having trouble writing the contents of a dataset to a csv file. I have made a solution that loops through the rows in the dataset, but it’s too slow. There must be a faster and...
2
by: darrel | last post by:
Our production web site went down today. We discovered that it was because the XML file we use to create the site navigation (most all of the controls on every page rely on this XML file) was only...
5
by: grinder | last post by:
first off, i am an extreme newbie to C. i am an undergrad research assistant and i have been shifted to a project that involves building a fairly involved c program. The part that i am stuck on now...
16
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.