• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 948
  • Last Modified:

Strip Quotes outta CSV file

Hi all

Need to strip out quotes outta CSV routine........ have outputted CSV file... need to open it and remove all quote markes

How? Need it quick please

cheers George
0
Geo123
Asked:
Geo123
1 Solution
 
arif_eqbalCommented:
Remove Quote mark?? Single or double
Anyway

Read it All in a String say Str

then for single quotes write

Str=Str.Replace("'", "")
it is a single Quote within double Quotes as the first argument and empty string as the second

For Double Quotes try this

Str=Str.Replace("""", "")

First argument has Four Double Quotes (actually one quote is required to escape the other)


0
 
checooCommented:
'Get a StreamReader class that can be used to read the file
        Dim inStreamReader As StreamReader
        inStreamReader = File.OpenText("myFileName")

        'Now, read the entire file into a string
        Dim contents As String = inStreamReader.ReadToEnd()
        inStreamReader.Close()
        contents = contents.Replace("'", "")
        Dim outStreamWriter As StreamWriter = New StreamWriter("myFileName")
        outStreamWriter.Write(contents)
        outStreamWriter.Close()
0
 
Geo123Author Commented:
its a double quote... how do I search for chr$(34) like what I used to in old VB6???

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Geo123Author Commented:
ok that worked...... I used """"

So I have to call this from access and supply name to .net exe... how do I do that??

or How would I strip out the " in Access or VB6??? How would I read file into string in Access / VB6?

cheers

George
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
For VB6...

Option Explicit

Private Sub Command1_Click()
    replaceInFile "C:\someFile.txt", """", ""
End Sub

Private Sub replaceInFile(ByVal fileName As String, ByVal oldString As String, ByVal newString As String)
    Dim ff As Integer
    Dim entireFile As String
   
    If Dir(fileName) <> "" Then
        ff = FreeFile
        Open fileName For Binary Access Read As #ff
        entireFile = Input(LOF(ff), ff)
        Close #ff
   
        entireFile = Replace(entireFile, oldString, newString)
   
        ff = FreeFile
        Open fileName For Binary Access Write As #ff
        Put #ff, , entireFile
        Close #ff
    Else
        MsgBox fileName, vbCritical, "File not found"
    End If
End Sub
0
 
checooCommented:
for double quote my code should be modified as follows

'Get a StreamReader class that can be used to read the file
        Dim inStreamReader As StreamReader
        inStreamReader = File.OpenText("myFileName")

        'Now, read the entire file into a string
        Dim contents As String = inStreamReader.ReadToEnd()
        inStreamReader.Close()
        contents = contents.Replace("""", "") 'NOTE THE DIFFERENCE HERE
        Dim outStreamWriter As StreamWriter = New StreamWriter("myFileName")
        outStreamWriter.Write(contents)
        outStreamWriter.Close()
0
 
Geo123Author Commented:
yeah checoo I used your code above and then did """" but I have users with Access and locked down desktop.... am trying to avoid making this like Access &  .Net solution ..... cos I will hit security policy and I havent looked at that yet
0
 
checooCommented:
you had not mentioned anything about security policy in your original question, never the less, if you can elaborate on your above comment then i might be able to provide some help
0
 
Geo123Author Commented:
checoo..... I am currently deploying all .Net exes to my c drive as the .Net security policy wont let me run them from network drive. So I have loader program on C drive that copies down lates exe files from network then runs the program from the c drive.

All databases are held on Network drives

cheers George
0
 
Geo123Author Commented:
checoo...you had any chance to look at the Security policy issue?? ie Cant run any VB exes on network drives???

cheers  George
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now