Эта процедура сортирует
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
Sub Sort
Set rs = CreateObject("ADODB.Recordset")
If Arg(1) = "n" then
With rs
.Fields.Append "SortKey", 4
.Fields.Append "Txt", 201, 5000
.Open
Do Until Inp.AtEndOfStream
Lne = Inp.readline
SortKey = Mid(Lne, Arg(3), Arg(4) - Arg(3))
If IsNumeric(Sortkey) = False then
Set RE = new Regexp
re.Pattern = "[^0-9\.,]"
re.global = true
re.ignorecase = true
Sortkey = re.replace(Sortkey, "")
End If
If IsNumeric(Sortkey) = False then
Sortkey = 0
ElseIf Sortkey = "" then
Sortkey = 0
ElseIf IsNull(Sortkey) = true then
Sortkey = 0
End If
.AddNew
.Fields("SortKey").value = CSng(SortKey)
.Fields("Txt").value = Lne
.UpDate
Loop
If Arg(2) = "a" then SortColumn = "SortKey ASC"
If Arg(2) = "d" then SortColumn = "SortKey DESC"
.Sort = SortColumn
Do While not .EOF
Outp.writeline .Fields("Txt").Value
.MoveNext
Loop
End With
ElseIf Arg(1) = "t" then
With rs
.Fields.Append "SortKey", 201, 260
.Fields.Append "Txt", 201, 5000
.Open
Do Until Inp.AtEndOfStream
Lne = Inp.readline
SortKey = Mid(Lne, Arg(3), Arg(4) - Arg(3))
.AddNew
.Fields("SortKey").value = SortKey
.Fields("Txt").value = Lne
.UpDate
Loop
If Arg(2) = "a" then SortColumn = "SortKey ASC"
If Arg(2) = "d" then SortColumn = "SortKey DESC"
.Sort = SortColumn
Do While not .EOF
Outp.writeline .Fields("Txt").Value
.MoveNext
Loop
End With
ElseIf Arg(1) = "tt" then
With rs
.Fields.Append "SortKey", 201, 260
.Fields.Append "Txt", 201, 5000
.Open
Do Until Inp.AtEndOfStream
Lne = Inp.readline
SortKey = Trim(Mid(Lne, Arg(3), Arg(4) - Arg(3)))
.AddNew
.Fields("SortKey").value = SortKey
.Fields("Txt").value = Lne
.UpDate
Loop
If Arg(2) = "a" then SortColumn = "SortKey ASC"
If Arg(2) = "d" then SortColumn = "SortKey DESC"
.Sort = SortColumn
Do While not .EOF
Outp.writeline .Fields("Txt").Value
.MoveNext
Loop
End With
End If
End Sub
Сортировать
фильтр Сортировка {п | т | тт} {а | д} StartColumn EndColumn
фильтр на 0 8
Сортирует файл
n - extracts a number from the columns specified. Looks for the first number.
t - extracts a text string including spaces from the columns specified.
tt - extracts a text string discarding leading and trailing spaces from the columns specified.
a - sorts acending
d - sorts decending
startcolumn - the starting column
endcolumn - the ending column
Пример
фильтр сортировать n a 1 10 < "% windir% \ win.ini"
Записав его в файл. Если вы не можете сделать что-то такое основное, что вы спрашиваете? Напишите свой заголовок, напишите оставшуюся часть файла. – Noodles
Извините, я уже редактировал вопрос. Могу ли я создать файл csv, который может создать столбец заголовка, поэтому, когда пользователь нажимает на имя пользователя, он сортирует имя при входе или выходе. Это возможно? – user3696022
№ CSV - это просто текст с определенной структурой. Любой тип щелчка или сортировка зависит от программы, с которой вы открываете файл. –