Link to home
Start Free TrialLog in
Avatar of Nick Collins
Nick Collins

asked on

Searching Text Files - Appending New Data

Good Afternoon,

I have uploaded two text files called as follows





The main file is called 'Audit_HV_Type' it has a value under the heading Order Number: - the values are like this as example HV_000035_106116

In the other file it is called 'AuditPlot_HV_Type', in this file it contains two key values, 'Order Number' & 'Description'

I want to able to create a process that takes the 'Order Number' taken from file 'AuditPlot_HV_Type' and searches for value in the flle 'Audit_HV_Type' when it finds a match, I would like to append the description value at the end of the order Number. When it finds no match, ignore the line.

Example

File AuditPlot_HV_Type.txt

"HV_000035_1061168","Plot 17 kicker lift "

Searches for 'Order Number' 'HV_000035_1061168' in the file Audit_HV_Type.txt

When it finds a match append the description at the end of the order number

"20 July 2018 01:51 PM","User1","User2 ","HV_000035_1061168_Plot 17 kicker lift","admin@somewhere.com ","Contractor1"

It sounds simple - I hope you understand
Avatar of Bill Prew
Bill Prew

Will any of the fields, which I see are enclosed in double quotes, contain embedded commas?


»bp
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nick Collins

ASKER

Thanks for this.. I am taking a look at the script..

What do I need to do regarding path files of folder and files
What do I need to do regarding path files of folder and files
I don't understand your question?  The files involved are passed in to the script on the command line as I indicated, so just put them there.  Normal rules of executing any command or program in windows apply, if the files are not in the current directory that the script is executed from then you would need to fully qualify them with the path in the parms that you pass in.  Like:

cscript EE29109945.vbs "c:\temp\dir1\AuditPlot_HV_Type.txt" "c:\temp\dir2\Audit_HV_Type.txt" "c:\temp\dir3\Audit_HV_Type_New.txt"


»bp
Sorry it's been a very long time since I passed parameters through a command line..

trying to work out how i run the command line from the task scheduler
When setting up the job in task scheduler just make the program to run cscript.exe and the parameters:

EE29109945.vbs "c:\temp\dir1\AuditPlot_HV_Type.txt" "c:\temp\dir2\Audit_HV_Type.txt" "c:\temp\dir3\Audit_HV_Type_New.txt"


»bp