Transposing CSV Data (Rotate Rows to Columns)
How to transpose CSV files—swapping rows and columns. Use Excel Paste Special, Python Pandas, or online tools to reshape your data.
Transposing CSV Data (Rotate Rows to Columns)
Sometimes your data is "wide" when it needs to be "tall", or vice versa.
Original (Wide):
Name,Jan,Feb,Mar
Sales,100,200,150
Costs,50,60,55
Transposed (Tall):
Name,Sales,Costs
Jan,100,50
Feb,200,60
Mar,150,55
This operation is called Transposing.
Method 1: Excel "Paste Special"
- Open CSV in Excel.
- Select all data (Ctrl+A).
- Copy (Ctrl+C).
- Click on an empty cell (or new sheet).
- Right-click > Paste Special.
- Check the Transpose box (bottom right).
- Click OK.
Pros: Visual, easy. Cons: Manual; limited by Excel's row/column limits.
Method 2: Python (Pandas)
One line of code.
import pandas as pd
df = pd.read_csv('data.csv', header=None) # header=None if you want to rotate headers too
df_transposed = df.T
df_transposed.to_csv('transposed.csv', header=False, index=False)
Method 3: Online Tool
If you don't have Excel or Python handy.
When to Transpose?
- Charting: Chart tools often expect time series in rows, not columns.
- Database Import: Databases prefer "Tall" data (normalized) over "Wide" matrices.
- Comparison: It's often easier to compare metrics side-by-side (columns) than row-by-row.
Warning: Header Confusion
When you transpose, your Headers become the first Column. And your first Column becomes the Headers.
Ensure your data makes sense after rotation. You might need to rename the new header row manually.
Need to rotate data? HappyCSV can transpose your CSV file in seconds directly in the browser.
Related Articles
Anonymize CSV Data (GDPR/Testing)
How to mask sensitive data in CSV files. Anonymize names, emails, and phones for testing or GDPR compliance.
Batch Convert Multiple Excel Files to CSV
How to convert 100 Excel files to CSV at once. Use VBA macros, Python scripts, or batch converters to save hours of manual work.
Best Free CSV Viewers for Mac & Windows
Excel isn't the only way to open CSVs. Check out the best free CSV viewers like Tad, Miller, and online tools for large files.
Need to handle CSV files?
HappyCSV is the free, secure way to merge, split, and clean your data — all in your browser.