473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing table contents into a Text file

21 New Member
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_ta ble" 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 8050
improvcornartist
303 Recognized Expert Contributor
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
idealfellow
21 New Member
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 Recognized Expert Contributor
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
3776
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 displays these fileds and values in different ways so am creating one page and parsing variables to it. The problem appears to be in trying to write...
5
9951
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 when it comes to dealing with complex tree structures such as those that have multiple folders and sub folders. I have tried searching Code...
2
6844
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 replace just one item. I know I can get the entire array, then save the whole thing (with a for loop and if statements so that the changed data will be...
2
3656
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 page. The idea is to programmatically write style sheet code that dynamically goes into every page and is rendered accordingly. Let's assume I...
16
2188
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
6
4265
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 easier way. Here is a stripped down version of my failed attempt of writing without looping through the dataset:
2
1630
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 half-written. We're not sure why. One theory is that two people happened to modify the database at the exact same time thereby triggering the...
5
6189
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 is as follows: - i am trying to write code that will take any number of text inputs (names of other text files) and put them into a file...
16
7161
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 unchanged). How can I do that in Python? Claudio Grondi
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.