473,386 Members | 1,706 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,386 software developers and data experts.

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_Text As String = "test"
Dim stext As String = "bfsdbfbfebfe vswvgfsbefb_"
Dim Record As String = user + ",""USA""," + HtmlTable_0_Text,+
"""" stext, """
Dim Record1 As String = "Username"",""Countryname"",""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.Length - 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.Length - 1
Write(1, splitstring(i))

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

Nov 21 '05 #1
1 7534
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**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.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_Text As String = "test"
Dim stext As String = "bfsdbfbfebfe vswvgfsbefb_"
Dim Record As String = user + ",""USA""," + HtmlTable_0_Text,+
"""" stext, """
Dim Record1 As String = "Username"",""Countryname"",""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.Length - 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.Length - 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
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...
27
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...
2
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
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...
4
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,...
7
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...
2
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...
24
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...
4
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...
63
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...

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.