
17개의 .txt 파일 중에서 60개의 고유한 값을 찾아야 합니다. 이는 일반적으로 한 번에 하나 또는 두 개의 값을 받을 때 간단한 "찾기" 및 복사이며, 이 큰 목록에서는 분명히 작동하지 않을 것입니다.
스프레드시트에는 약 60개의 계좌 번호가 있습니다. 편집/완료를 위해 해당 계정 행을 다른 .txt 파일에 복사할 수 있도록 17개의 .txt 파일 중 하나에서 각 계좌 번호를 찾아야 합니다. .txt 파일은 ftp 아카이브에 있으므로 필요한 경우 Excel에 복사할 수 있지만 .txt 파일을 전혀 변경하지 않도록 주의해야 합니다.
조회 기능이 있다는 것을 알고 있지만 아직 익숙하지 않고 정확히 필요한 것이 무엇인지 잘 모르겠습니다. 이것에 대한 도움을 주시면 감사하겠습니다! 고마워요, 엘
답변1
도움이 될 만한 스크립트를 준비했습니다.
라는 폴더를 만듭니다.계정.vbs 확장자로 스크립트를 저장합니다.
계정 폴더에 다음과 같은 폴더를 만듭니다.입력. 검색할 모든 계정 파일을 입력 폴더에 복사합니다. 모두 .txt 파일이어야 하며 그렇지 않으면 무시됩니다.
라는 파일을 만듭니다.account_numbers.txt그리고 각 계좌번호를 별도의 줄에 기재하세요. 스크립트는 각 파일을 열고 한 줄을 읽고 모든 계정 번호와 비교하여 확인해야 합니다. 검색 결과는 다음 위치에 저장됩니다.account_found.txt. 보증 없이 제공되며, 사용에 따른 책임은 사용자 본인에게 있습니다. 도움이 되길 바랍니다.
' find all occurrances of an account number in a number of files
' place all account txt files into input folder
' accounts_found.txt is created if it is missing
' by 'Robert' 2017 - hereby placed into the Public Domain
' set some Constants here
Const ForRead = 1
Const ForWrite = 2
Const ForAppend = 8
Const OverWrite = True
Const NoOverWrite = False
Dim acct_num_list(100) ' max records for the array, num_accounts variable counts them anyway
inputFolderName = "input\" ' the folder where the txt files are
outputFileName = "accounts_found.txt" ' the output file for matched records
accountsFileName = "account_numbers.txt" ' the file which contains account numbers to search for
' = = = Start of Code = = =
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set outFile = objFSO.OpenTextFile(outputFileName, ForWrite, OverWrite)
Set objInputFolder = objFSO.GetFolder(inputFolderName)
Set sFileCollection = objInputFolder.Files
Set accounts_file = objFSO.OpenTextFile(accountsFileName, ForRead)
num_accounts = 0
DO While Not accounts_file.AtEndOfStream
acct_num_list(num_accounts) = accounts_file.ReadLine
num_accounts = num_accounts + 1
Loop
accounts_file.Close
For Each objFile in sFileCollection
If UCASE(objFSO.GetExtensionName(objFile)) = "TXT" then
Set sourceFile = objFSO.OpenTextFile(inputFolderName & objFile.Name, ForRead)
Do While Not sourceFile.AtEndOfStream
curr_line = sourceFile.ReadLine
For counter = 0 to num_accounts
if instr(1, curr_line, acct_num_list(counter),1) >= 1 then
outFile.WriteLine curr_line
End If
Next
Loop
End If
Next
' = = = End Of File = = =