If you're doing this to try and load up a table in a relational database system then it is worth looking at using SQL to do the 'transposing'. In relational-database-land they call this denormalisation and the technique in SQL looks like a lighter coding task than it does for TI. MSDN has some information:
Denormalized view for normalized tables
And this link shows a simple and more comprehensible worked example:
How to Denormalize a Normalized Table Using SQL
For our purposes, the way TM1 arranges a view for processing in a TI (a 'view extract') is effectively normalising a view you look at in the cube.
Also note that in TI you can run into problems with things like general ledger data. For example, if following Marcus' (very good) advice to:
Marcus Scherer wrote:... use the parent of your 12 month elements in your source view.
Consider a sequence of balances like this:
FY | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
0 | 0 | 0 | 100 | -100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
If the view is zero suppressed then the Full year element will be suppressed in this case and therefore won't get picked up in the datasource view. To code around this, you need an attribute on the account to use as the output flag rather than the Full Year result. As you can see, the is now getting more elaborate and there could be further exceptions required.So, for some cases, the SQL method may be a simpler way of getting data in the database, if that is what you are trying to do.