473,804 Members | 3,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read and Write to TextFile with

Sam
Hi guys

If I have to read/write a text file which has the following format, what
would be the best way to read it? Should I readline method of the
streamreader to a string variable and parse it to the format below?

1 0.000016 7.999882 0.000000
2 1.000013 7.999875 0.000000

Many thanks

Sam
Nov 21 '05 #1
2 1106
What *exactly* is the structure? Are the individual data items
separated by spaces? Tabs? Is each line delimited with a CR LF?
From the looks of it, using ReadLine would work to read the data in and

WriteLine to write it back out. You can use the various string
formatting commands to format the output string the way you want it.

Hope this helps

Nov 21 '05 #2
Sam
Chris

Thanks for the suggestions. The readline method works great when I read the
input data and display it in a text box.

Sam

"Chris Dunaway" <du******@gmail .com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
What *exactly* is the structure? Are the individual data items
separated by spaces? Tabs? Is each line delimited with a CR LF?
From the looks of it, using ReadLine would work to read the data in and

WriteLine to write it back out. You can use the various string
formatting commands to format the output string the way you want it.

Hope this helps

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1690
by: Christian Blackburn | last post by:
Hi Gang, I have so far been unable to get the TextStream Object to write on Fat32. I'm using Windows 2000 Pro Sp4. Scripts have write access and I even tried giving IUSR user level writes and still when I tried loading the ASP page it just hangs trying to create the file :(. <% Function WriteText(sPath, sText) Dim fso, TextFile
2
9951
by: Tim Bücker | last post by:
Hello. Is there a way to read a specified line in a textfile? Something like TextReader.ReadTextLine(4); It seems very odd to use reader.ReadLine(); reader.ReadLine(); reader.ReadLine(); string wishedLine = reader.ReadLine();
3
8573
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our naming standard (unique id) and create them designated folder. This requirement should be created as a batch job and preferrably this job should monitor the folder where one big chunk of text file lands and process them immediately. ...
2
1473
by: Tim | last post by:
Greetings, I need to read the contents of a textfile to memory and then write these contents to another location. I was thinking of reading this data into a datareader, but I don't see anything for that, sqlDataReader, OleDBDatareader. Could someone tell me was kind of object I should read the textfile data into? Thanks,
9
3466
by: Justme | last post by:
Novice programmer needs help with using fgets to read and ignore the first two lines of a file. I've gone thru the previous posting regarding fgets, but none of them seems to help my situation. I have airdata file that i have to read, but in other teh fscanf to work properly, i need to ignore the first two lines, because scanf does not read spaces. This is what my current code looks like #include <stdio.h>
2
3271
by: RaviRajhulk | last post by:
I am trying to read folder and subfolder and print their name into a text file.I am able to read the folder and its content and write it to the textfile but I am not able to read the content of the subfolder and write its content..FOR Eg : I have folder1\text1 folder1\text2 folder1\folder2\text3 I am reading folder1 and it is writing text1,text2 and folder2 in another textfile.I need to print the total structure of the subfolder ..like...
0
1413
by: Snoze | last post by:
Hello, I'm trying to make an application with C# that writes and reads some lines of a text file, but I want to read one specific line and save the text in a string variable. And the inverse process, save a string variable in a specific line of the text file. Also i think that it could be done writing in the textfile "first= Here the text of the first line", "second= here the text of the second line"... and then, my application when want to...
6
7074
by: Per Juul Larsen | last post by:
Hi. My Textfile looks like this Variable 1 Variable 2 Variable 3 Variable 4 On opening the application it will read the textfile, and assign each line of variable to at textfield in VB and then close the file.
3
2234
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I am trying to loop a Textfile. This Textfile is located on a shared drive and it is used by another process. When I try to read it I get an exeption: The process cannot access the file 'file.log' because it is being used by another process.
2
1700
by: vasanthspiky28 | last post by:
the below code displays the details of tittles from a table papers wat i nee is f i click the displayed tittle a textfile of that tittle should get opened help me..<% Dim con,rs,sl set con=server.CreateObject("ADODB.Connection") set rs=server.CreateObject("ADODB.Recordset") con.open Application("db") sl = "SELECT * FROM papers " rs.Open sl,con Response.Write "<table width='100%'>" Do While Not rs.EOF
0
10575
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
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.