Login | |
|
 |
Re: search multiple text files for elevations - 5/25/2005 12:34:54 AM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
So, if I am understanding you right, you have your DEM files which contain, in space delimited format, 3 entries, (Eastings, Northings, Elevations). Then you have your "site" file which will contain what? Eastings and Northings? If that is in fact what they are, what you want to is compare what you have in your site file to what is in a particular DEM, if it matches write that line to a results file. i.e. DEM contains 123 456 78.9 987 654 32.1 Site contains 123 456 Results will contain 123 456 78.9 is this what you are looking for?
|
|
| |
|
|
|
 |
Re: search multiple text files for elevations - 5/31/2005 2:57:11 PM
|
|
 |
|
| |
bevan
Posts: 3
Score: 0
Joined: 5/24/2005
From:
Status: offline
|
This is what i came up with: not pretty but seems to work... Option Explicit Dim objFSO, objSearchFile, objOutputFile, objLogFile, objDataFile, strComputer, objWMIService, FileList Dim strText, arrSites, tempFile, output, temp, strSite, objFile Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objSearchFile = objFSO.OpenTextFile _ ("c:\Bevan\Combining_Tool\rainfall_sites.txt", ForReading) '("c:\Bevan\Combining_Tool\test.txt", ForReading) Set objOutputFile = objFSO.CreateTextFile("output.txt") Set objLogFile = objFSO.CreateTextFile("log.txt") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set FileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='C:\Bevan\Combining_Tool\RENAMED_XYZ_tab_delimited_files'} Where " _ & "ResultClass = CIM_DataFile") 'creates a list of all files in folder '("ASSOCIATORS OF {Win32_Directory.Name='C:\Bevan\Combining_Tool\testgrds'} Where " _ ' & "ResultClass = CIM_DataFile") strText = objSearchFile.ReadAll 'reads all of search file (sites to find) into a string objSearchFile.Close arrSites = Split(strText, vbCrLf) 'splits the string based on vbCrLf creates an array 'arrSites contains all the sites for which elevations are needed For Each objFile In FileList Set objDataFile = objFSO.OpenTextFile(objFile.Name, ForReading) 'Wscript.Echo objFile.Name & " File name" objLogFile.Writeline objFile.Name Do Until objDataFile.AtEndOfStream temp = objDataFile.ReadLine For Each strSite in arrSites If UCase(Left(temp,15)) = strSite Then objOutputFile.Writeline temp End If Next Loop objDataFile.Close Next Wscript.Echo "Finish
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|