close
I've got a CSV file to which I need to add a header line. I wrote a
little VB Script to do this. Once I ran it the size of the file
literally doubled. The header line is there now, however. When I open
the file in Excel, however, all the text in each line opens in one
cell. It's quite annoying. Has anyone seen this before? Okay, maybe
not the exact problem, but maybe where Excel won't open a CSV
correctly? I'm thinking there must be some odd character or something
in it that causes this, but the file quot;looksquot; normal.

Thanks for any suggestions,
Jennifer

Just in case anyone is interested, this is the script does:

Dim DtlHdrDim FilePath
Dim DtlName
Dim FSO, Fil, TempFile, TempName
Dim sLine

Const ForReading = 1, ForWriting = 2, ForAppending = 8

FilePath = quot;\\hqimpact\mktdata\Extract\quot;
DtlName = FilePath amp; quot;SalesDtl.csvquot;
TempName = FilePath amp; quot;Temp.csvquot;

Set FSO = CreateObject(quot;scripting.filesystemobjectquot;)

DtlHdr =
quot;parSalesHdrID,parSalesDetailID,Before,Quantity,Af ter,Promo,PromoBeforequot;
amp; _
quot;ItemPrice,PromoAfter,POSItem,UnitNumber,Deple tedquot;

Set Fil = FSO.OpenTextFile(DtlName, ForReading, False)
sLine = Fil.ReadLine

If sLine lt;gt; DtlHdr Then
Set TempFile = FSO.CreateTextFile(TempName,ForWriting, True)
TempFile.WriteLine DtlHdr
Do Until Fil.AtEndOfStream
sLine = Fil.ReadLine
TempFile.WriteLine sLine
Loop

Fil.Close

FSO.CopyFile TempName, DtlName, True
TempFile.Close
FSO.DeleteFile TempName
End If

Set Fil = Nothing
Set FSO = Nothing
arrow
arrow
    全站熱搜

    software 發表在 痞客邦 留言(0) 人氣()