Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise.

Example:
File1:
1|AAA|25|2
5|qqe|20|7
4|wer|31|81

I need to create a second file in which data can be inserted in a columnwise manner i.e.
File2:
AAA|25|1|2
qqe|20|5|7
wer|31|4|81

The order of columns in file1 and file2 need not be same as illustrated in the example. Lets say, I need to pick up column2 of file1 and it should be column1 in file2 and so on..
Could you please suggest how do I go about it?

The mapping of columns is done dyanamically...i.e. assigning the column to be mapped to a variable by reading it from a mapping file

No duplicate or cross-posting, read the rules.

Proceed here:

Thread closed.