Automated Text File Manipulation in DOS or Windows

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
73,803
Office Version
  1. 365
Platform
  1. Windows
Let me preface this by saying that we need the following to be done is something that will run on DOS/Windows (and not Unix) and will not require the purchase of any new software. I imagine it can probably done with some sort of Scripting language.

We have a fixed width, space delimited text file. Each line is 803 spaces long. Space 803 is an indicator that indicates whether the record is a Participant Record (value = 1), or a Detail Record (value = 2). Each and every Participant Record is immediately followed by some number of Detail Records (at least 1 for each Participant).

On the Detail Records (2), there is important identifying information in spaces 794-802. Unfortunately, this data also needs to be placed the Participant Records (1) for index purposes, but does not exist there.

So there are two things we would like to do. The first is essential, but the second is less important and we can work around it other ways.

1. We need to add the index from the Detail Records (2) found in spaces 794-802 to the Participant Record (1) in spaces 1-9. I envision that whis is how it would work logically: Loop through all the records, when you come to a record with the value of 1 in space 803, copy the value found in spaces 794-802 of the NEXT record, and paste it in spaces 1-9.

2. After we are finished with Step 1, split the text files into two text files, one that contains all the Participant Records (1), and one that contains all the Detail Records (2).

The goal, after we finish writing script to do this is to program it with a batch file to do this automatically.

Any advice is appreciated.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top