Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Removing double quotes from a a CSV file being created.  VB 2005

Posted on 2006-10-19
4
Medium Priority
?
287 Views
Last Modified: 2008-02-01
Hello,
 
I found several similar posts, but the documented solution didn't work for my program.

Here's my CSV file opened in Notepad:

"JF7","10192006","ARP","0.4"

The file would be good if I could drop all of the "



Here's my string values, I tried the ("""""", """") but didn't make a different  (I had to use double quotes around old value and new value to avoid error about quot not being declared)

CompanyCode = "JF7"

strCurrentDate = CurrentDate.ToString("MMdyyyy").ToString
strCurrentDate.Replace("#", "")
strCurrentDate.Replace("""""", """")

RegHrs = dsADP.Tables("tblTA_ADP_Hrs").Rows(i)("Regular_Hours").ToString



Here's my file creation:

WriteLine(1, CompanyCode, strCurrentDate, Emp, RegHrs)


Please help!

Thanks,
Jon
0
Comment
Question by:JMO9966
  • 2
4 Comments
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 400 total points
ID: 17767542
read in the csv file
dim a as string= myfilestream.readtoend()
a=replace(a,chr(34),"")

write to csv file
a contains your whole file
0
 

Author Comment

by:JMO9966
ID: 17768657
Thanks Gangwisch,

I get an error on the last line here.  It doesn't like my (a) argument I'm passing??


        Dim ADPFile As StreamReader
        Dim ADPFileOutput As StreamWriter

        ADPFile = File.OpenText("c:\jb\custom programs\adp\adp.csv")

        Dim a As String = ADPFile.ReadToEnd()
        a = a.Replace(Chr(34), "")

        ADPFileOutput = File.WriteAllLines("c:\jb\custom programs\adp\PRJ7FEPI.csv", a)
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 600 total points
ID: 17768864
You appear to be using VB.Net 2005:

        Dim inFile As String = "c:\jb\custom programs\adp\adp.csv"
        Dim outFile As String = "c:\jb\custom programs\adp\PRJ7FEPI.csv"
        File.WriteAllText(outFile, File.ReadAllText(inFile).Replace(Chr(34), ""))
0
 

Author Comment

by:JMO9966
ID: 17769402
Thanks guys!!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Integration Management Part 2
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question