|
本帖最后由 蓝天630902 于 2012-5-10 21:38 编辑
以深圳市场为例,如果它的日线数据在D:\Program Files\tdx\Vipdoc\sz\lday
然后,在通达信里新建一个目录:D:\Program Files\tdx\Vipdoc\csv\:
MkDir "D:\Program Files\tdx\Vipdoc\csv\"
以下程序输出格式为*.csv,可以用excel直接打开:
Type MyType
a1 As Long '日期
a2 As Long '开盘价
a3 As Long '最高价
a4 As Long '最低价
a5 As Long '收盘价
a6 As Long '成交金额
a7 As Long '成交量
a8 As Long '未知
End Type
Sub 批量归类通达信据数据()
Dim fso, fldr, s
Dim b As MyType
Dim aFolder As String
aFolder = "D:\Program Files\tdx\Vipdoc\sz\lday\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder(aFolder)
k = ""
For Each s In fldr.Files
nm = s.Name
Open s For Binary Access Read As #1
i = 2
Do While Not EOF(1)
Get #1, , b
Open "D:\Program Files\tdx\Vipdoc\csv\" & b.a1 & ".csv" For Append As #2 '以追加方式打开文件
Print #2, Replace(nm, ".day", "") & "," & k & "," & b.a2 / 100 & "," & b.a3 / 100 & "," & b.a4 / 100 & "," & b.a5 / 100 & "," & b.a6 / 100 & "," & b.a7
Close #2
k = b.a5 / 100
Loop
Close #1
Next
Set fso = Nothing
End Sub
|
|