Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:10+00:00 2026-05-27T04:05:10+00:00

I have a lot of tab delimited data that is organized into multiple rows

  • 0

I have a lot of tab delimited data that is organized into multiple rows and should be all in two rows. Now it looks like this:

    Some Key    Other key   Foo Key    Bar Key
     0           5           18         12

    More Key    Dor key     Gee Key    Francis Scott  Key
     19          14          8          0

    Wa Key      Whis key    Don Key    Luh Key
     0           2           8          16

And I need it to look like this:

    Some Key    Other key   Foo Key    Bar Key    More Key    Dor key     Gee Key    Francis Scott  Key    Wa Key      Whis key    Don Key    Luh Key
     0           5           18         12         19          14          8          0                    0           2           8          16

I’ve got a few hundred csv files with about 20 rows each, 30 columns, so I want to script my way through this as much as possible. I’m using Python CSV, but I can’t figure out how to explain myself to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:05:11+00:00Added an answer on May 27, 2026 at 4:05 am

    This should do it:

    import csv
    import sys
    
    keys = []
    values = []
    
    reader = csv.reader(sys.stdin, delimiter="\t")
    for row in reader:
        keys.extend(row)
        values.extend(next(reader))
    
        # skip empty line
        assert next(reader, []) == []
    
    writer = csv.writer(sys.stdout, delimiter="\t")
    writer.writerow(keys)
    writer.writerow(values)
    

    Save this as thingie.py and run it with python thingie.py < sample.csv (where “sample.csv” is your data file)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimited table that has multiple columns (1500) and a few
I have HTTP header request and reply data in tab delimited form with each
I created a custom control that looks a lot like the tab buttons in
I have lot of products with custom options, now I have requirement to update
I have lot of code in my Tornado app which looks like this: @tornado.web.asynchronous
At the moment, I have lot's of Java which does all kind of nifty
I am creating Excel file download using NOPI libraries. I have lot of data
I am trying to build a data mart. I have lot of dimensions, and
I have a lot of pages that are setup like so from an old
I have a lot of log files that I wish to extract the distinct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.