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

Home Posts Topics Members FAQ

how to not write over lines in vb.net csv file

D
i have something where i am parsing information into a csv file with
created headers. the script gets replayed as it tests several user
profiles. how can i get it to continue writing on the last line (and
not rewrite over info.) of the file where it left off?
on another note, how to get rid of extra quotes in the csv file output?
vb.net 2003 doesnt like when i take them off or add on more.
this is what I have now:

Dim user As String = "V C"
Dim HtmlTable_0_Tex t As String = "test"
Dim stext As String = "bfsdbfbfeb fe vswvgfsbefb_"
Dim Record As String = user + ",""USA""," + HtmlTable_0_Tex t,+
"""" stext, """
Dim Record1 As String = "Username"",""C ountryname"","" Welcome
Screen"",""Html Link"",""Window displayed"
Dim i As Integer
Dim Recordarray() As String

Dim Recordcount As Integer
FileOpen(1, "C:\Axlrose.csv ", OpenMode.Output )

Do Until Recordcount = 2
Recordcount = Recordcount + 1

If Recordcount <> 2 Then

Dim splitstring() As String = Split((Record1) , ",")
For i = 0 To splitstring.Len gth - 1
' Write(1, splitstring(i))

If i = 4 Then
MsgBox("test")
WriteLine(1, splitstring(i))

Else
Write(1, splitstring(i))
End If
Next

FileClose(1)
Else
Dim splitstring() As String = Split((Record), ",")
FileOpen(1, "C:\Axlrose.csv ", OpenMode.Append )

For i = 0 To splitstring.Len gth - 1
Write(1, splitstring(i))

Next
FileClose(1)
End If
Loop
End Function
End Class

Nov 21 '05 #1
1 7560
Change the open line to
FileOpen(1, "C:\Axlrose.csv ", OpenMode.Append )

This should append to the end of the file instead of overwriting it.

"D" <da**********@g mail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
i have something where i am parsing information into a csv file with
created headers. the script gets replayed as it tests several user
profiles. how can i get it to continue writing on the last line (and
not rewrite over info.) of the file where it left off?
on another note, how to get rid of extra quotes in the csv file output?
vb.net 2003 doesnt like when i take them off or add on more.
this is what I have now:

Dim user As String = "V C"
Dim HtmlTable_0_Tex t As String = "test"
Dim stext As String = "bfsdbfbfeb fe vswvgfsbefb_"
Dim Record As String = user + ",""USA""," + HtmlTable_0_Tex t,+
"""" stext, """
Dim Record1 As String = "Username"",""C ountryname"","" Welcome
Screen"",""Html Link"",""Window displayed"
Dim i As Integer
Dim Recordarray() As String

Dim Recordcount As Integer
FileOpen(1, "C:\Axlrose.csv ", OpenMode.Output )

Do Until Recordcount = 2
Recordcount = Recordcount + 1

If Recordcount <> 2 Then

Dim splitstring() As String = Split((Record1) , ",")
For i = 0 To splitstring.Len gth - 1
' Write(1, splitstring(i))

If i = 4 Then
MsgBox("test")
WriteLine(1, splitstring(i))

Else
Write(1, splitstring(i))
End If
Next

FileClose(1)
Else
Dim splitstring() As String = Split((Record), ",")
FileOpen(1, "C:\Axlrose.csv ", OpenMode.Append )

For i = 0 To splitstring.Len gth - 1
Write(1, splitstring(i))

Next
FileClose(1)
End If
Loop
End Function
End Class

Nov 21 '05 #2

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

Similar topics

16
3042
by: nephish | last post by:
Hey there, kinda newbie question here. i know how to read the lines of a txt file. i know how to write a txt file. but how do i overwrite a line value with another value ? i mean, how do go to, say, line 3 of a text file and replace what is written on line 3 with something else?
27
5701
by: Sune | last post by:
Hi! Pre-requisites: ------------------- 1) Consider I'm about to write a quite large program. Say 500 K lines. 2) Part of this code will consist of 50 structs with, say, no more than at most 1K bytes of data. 3) These structs are to be used by all of the other 500K lines in various places.
2
6801
by: VM | last post by:
Is it possible to open an ascii file, read the first 499 lines, overwrite line 500 with the new string, and close the file? All the lines before and after line 500 will be untouched. Thanks.
12
11141
by: Nina | last post by:
Hi there, What is the maximum length that one line can hold in a text file using StreamWriter's Write or WriteLine method? If the string is too long for one line to hold, what will Write or WriteLine do? In order me to retrieve data correctly from the text file later, I have to know the right index. For the following code,if str1's length exceeds one line in text file, how can I get str2's index when reading the text file? Is there...
4
6876
by: welch | last post by:
while taking some rough disk performance measures on windows machines, and snooping with FileMon, i've noticed some odd behavior here's the little nul-writer i'm running: def writeTest(nBlocks, blockSize): """write nBlocks*blockSize nuls to a file""" f = open("writeTest.out", "wb") nulBlock = '\0'*blockSize while nBlocks: f.write(nulBlock)
7
2841
by: nonameisfree | last post by:
I am trying to get StartUp-Manager to write the grub password in encrypted form to menu.lst. Currently it writes the password in plain-text and that is not too clever... This is the function I currently use: def on_update_password_button_clicked(self, widget): if self.password_entry.get_text() == self.confirm_password_entry.get_text(): password=self.password_entry.get_text() if...
2
11327
by: =?Utf-8?B?RGFtZW9u?= | last post by:
Hi - I am attempting to write lines to a file at high volume, multiple threads. Here is my scenario: (initial "WriteToFile" object created via a parent multithreaded process, which receives files, can call custom code for each file received - much like BizTalk) 1. Receive multiple files, each file received creates a "WriteToFile" object
24
4461
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone help out a newbie? #include <stdio.h> #include <ctype.h> #include <string.h>
4
1315
by: Curious | last post by:
I have a file to which I'll need to at first read until it locates the last line of string. According to content of the last line of string, I'll need to write something to this file right after the last line of string. This requires that I'll need a StreamReader at first (to read one line at a time), until the last line is read. Then I'll need a StreamWriter to point to the end of the file, and
63
3271
by: Bill Cunningham | last post by:
I don't think I can do this without some help or hints. Here is the code I have. #include <stdio.h> #include <stdlib.h> double input(double input) { int count=0,div=0; double mean=0,linput=0; FILE *fpr, *fpw;
0
9706
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
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...
1
10317
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
10075
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...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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();...
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.