I need to create a script to process on 10 files. Mentioned below is one of those file and the requirement.
Input File
DCIA_GEOG_DATA_OCEAN.TXT
Sample Record
"Terr","TerrName","Dist","DistName","REGION","RgnName","BCName"
"A0010000","Abilene TX A 1","A0010957","Dallas TX","A0010998","West","US HEADQUARTERS"
"A0010001","Akron OH A 1","A0010954","Cleveland OH","A0010997","Central","US HEADQUARTERS"
"A0010002","Alaska AK A 1","A0010991","Seattle WA","A0010998","West","US HEADQUARTERS"
The output removes the qoute and makes the file a pipe delimited and adds a null field before the last field and a field after the last field.
The last field should be populated with the word which comes after the last "_" and before ".txt in file name"(OCEAN in this case)
Output record needed:
A0010000|Abilene TX A 1|A0010957|Dallas TX|A0010998|West||US HEADQUARTERS|OCEAN
A0010001|Akron OH A 1|A0010954|Cleveland OH|A0010997|Central||US HEADQUARTERS|OCEAN
A0010002|Alaska AK A 1|A0010991|Seattle WA|A0010998|West||US HEADQUARTERS|OCEAN
Awesome Pamu. That really solves the issue. Just wanted to know if i have 10 files. and have to perform the above processing with all files and then i need to concatenate all files into a single file . what should be the approach?
Should i use your code 10 times on each file and create 10 temp files? and then concatenate them into a single file? Will the above code handle the commas if there are any between the double qoutes?