Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swith columns/rows in a tab delimited text file

Status
Not open for further replies.

jtb1492

Technical User
Mar 17, 2005
25
US
How can I switch the cloumns and rows of a tab delimited text file?

I can't use an array of arrays or anything like that because there is a LOT of data in the file and it takes forever that way. I was think read a row, write it to the output file, then read a row from the input file, and add each element to the end of a line in the output file, etc. I'm no good at working with file in a way this advanced (using perl for a week now).

Thanks, all.
 
How much data do you consider a LOT of data? My vote would have been for using an Array of Arrays.

You may be able to accomplish what you want (appending each input column to the end of a row/line in an output file) using the Tie::File module. However, if you have enough data, it might be slow no matter how you approach the problem.
 
Lets say 20,000 columns and 500 rows of data.
I tried an array of ararys and it takes like 30 minutes.
 
post the code you have been trying, might be another reason for the slow process time other than the amount of data.
 
rharsh said:
My vote would have been for using an Array of Arrays.
KevinADC said:
post the code you have been trying, might be another reason for the slow process time other than the amount of data.
Ditto to both.


 
I got it! It hit me last night. I am such an idiot. I guess this is what happens when you don't write any code for 10 years.

For some reason I was stuck on working with the data as numbers, since it is all numbers. But then it hit me that I should just work with it as text. So I have one array for each row I want in the output file. I read the first column into the arrays, the concatinate the second column onto the arrays I set up. It's really fast and simple that way!
 
I guess this is what happens when you don't write any code for 10 years.
I thought what happened was you became a Project Manager and started telling programmers how to do their jobs.
[hammer]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top