用VBA?
Sub 提取文本()
Dim i&, j&
Dim files
Dim a As String
Dim arr, ar()
i = 2
files = Application.GetOpenFilename(, , "打开文件")
If files = False Then MsgBox "你未选择文件,程序即将退出!": Exit Sub
Open files For Input As #1
Do While Not EOF(1)
Line Input #1, a
If a <> "" Then
arr = Split(Replace(a, """", ""), ":")
j = Len(a) - Len(Replace(a, ":", ""))
Cells(i, 1) = Left(arr(1), InStr(arr(1), ",") - 1)
Cells(i, 2) = Left(arr(2), InStr(arr(2), ",") - 1)
If j = 3 And Right(arr(2), InStr(arr(2), ",")) = "年龄" Then
Cells(i, 3) = arr(3)
Else
If j = 3 And Right(arr(2), InStr(arr(2), ",")) = "身高" Then
Cells(i, 4) = arr(3)
Else
If j = 4 Then
Cells(i, 3) = Left(arr(3), InStr(arr(3), ",") - 1)
Cells(i, 4) = arr(4)
End If
End If
End If
i = i + 1
End If
Loop
Close #1
End Sub
|