+ Reply to Thread
Results 1 to 2 of 2

Text qualifier " created when using I/O to write a text file

Hybrid View

  1. #1
    Forum Contributor PingPing's Avatar
    Join Date
    02-19-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    158

    Text qualifier " created when using I/O to write a text file

    I've got a problem when using the Write I/O command.
    The original file has data without any Text Qualifiers.
    However when I write the data to a new file, it's written WITH the Text Qualifier " surrounding each row/line.

    For example:

    Original File:

    line1
    line2
    ...

    Written file:

    "line1"
    "line2"
    ...

    Does anyone knows how to stop this?

    My code is:

    Public Sub CreateMergedFile()
              
              Dim strHeaderFile As String
              Dim strMainFile As String
              Dim strFooterFile As String
              Dim strOutputFile As String
              
              Dim lngHeaderFileNum As Long
              Dim lngMainFileNum As Long
              Dim lngFooterFileNum As Long
              Dim lngOutputFileNum As Long
              
              Dim strLine As Variant
              
              strHeaderFile = "i:\BBDRV_Header.txt"
              strMainFile = "i:\STDERIVEDFI.out"
              strFooterFile = "i:\BBDRV_Footer.txt"
              strOutputFile = "i:\stderivedfi_test.txt"
              
              lngOutputFileNum = FreeFile
              Open strOutputFile For Output Access Write As #lngOutputFileNum
    ' Header
                        lngHeaderFileNum = FreeFile
                        Open strHeaderFile For Input As #lngHeaderFileNum
                        Do While Not EOF(lngHeaderFileNum)
                                  Input #lngHeaderFileNum, strLine
                                  If StrComp(strLine, "IGNORETHIS|ISIN|", vbTextCompare) = 0 Then
                                            ' do nothing, ie. ignore it
                                  Else
                                            Write #lngOutputFileNum, strLine
                                  End If
                        Loop
                        Close #lngHeaderFileNum
    ' Main
                        lngMainFileNum = FreeFile
                        Open strMainFile For Input As #lngMainFileNum
                        Do While Not EOF(lngMainFileNum)
                                  Input #lngMainFileNum, strLine
                                  Write #lngOutputFileNum, strLine
                        Loop
                        Close #lngMainFileNum
    ' Footer
                        lngFooterFileNum = FreeFile
                        Open strFooterFile For Input As #lngFooterFileNum
                        Do While Not EOF(lngFooterFileNum)
                                  Input #lngFooterFileNum, strLine
                                  Write #lngOutputFileNum, strLine
                        Loop
                        Close #lngFooterFileNum
                        
              Close #lngOutputFileNum
    
    End Sub

  2. #2
    Forum Contributor PingPing's Avatar
    Join Date
    02-19-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    158

    Re: Text qualifier " created when using I/O to write a text file

    A the risk of American-izing the forums....

    My Bad

    **culturally cringes**
    It seems I should have used the Print statement and NOT the Write statement.
    Problem now fixed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1