Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

How can I use a Powershell script to output data for an Invoice

Input Data, in a file called Source.txt

ISA*00*          *00*          *12*1234567891     *ZZ*COMPANYCOL     *213456*1234*A*00123*123000010*1*P*>~
GS*IN*2134567891*1234567891*20141024*1234*00*X*001234~
ST*999*1234561~
BIG*20141020*123456.*20140917*1234567.~
N1*RI*COMPANY*0*000000000~
N1*BT*COMPANY 2*0*12345678910000~
ITD*00*2*****00~
DTM*000*20141020~
FOB*CC~
IT1*1*200*CA*5.4**UN*123456789123*VN*01234A~
IT1*2*50*CA*1.4**UN*213456789122*VN*02345A~
IT1*3*60*CA*12.4**UN*789456123123*VN*06789A~
TDS*1234567~
ISS*1234*CA*12345*LB~
SE*12*123456~
GE*1*10~
IEA*1*123000010~


For each ISA to IEA data set in file, and there could be several, I would like the following
desired Output Data, in a file called Output.txt:

Company:  COMPANYCOL  (these are the words next found next to ZZ)
Type of document:  999  (these are the numbers next to the ST)
Identifier: 123000010  (the number found in IEA)

Then below the above output, I would like a blank line, and then I would like the data from the Source.txt to be displayed underneath it.

So the Output.txt file should look something like this, in this case:

Company:  COMPANYCOL
Type of document:  999
Identifier: 123000010


ISA*00*          *00*          *12*1234567891     *ZZ*COMPANYCOL     *213456*1234*A*00123*123000010*1*P*>~
GS*IN*2134567891*1234567891*20141024*1234*00*X*001234~
ST*999*1234561~
BIG*20141020*123456.*20140917*1234567.~
N1*RI*COMPANY*0*000000000~
N1*BT*COMPANY 2*0*12345678910000~
ITD*00*2*****00~
DTM*000*20141020~
FOB*CC~
IT1*1*200*CA*5.4**UN*123456789123*VN*01234A~
IT1*2*50*CA*1.4**UN*213456789122*VN*02345A~
IT1*3*60*CA*12.4**UN*789456123123*VN*06789A~
TDS*1234567~
ISS*1234*CA*12345*LB~
SE*12*123456~
GE*1*10~
IEA*1*123000010~
ASKER CERTIFIED SOLUTION
Avatar of Joe Klimis
Joe Klimis
Flag of United Kingdom of Great Britain and Northern Ireland image

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 E=mc2

ASKER

Works very well, excellent.