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

  • Home
  • SEARCH
  • 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 8834409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:00:28+00:00 2026-06-14T09:00:28+00:00

I found some helpful stuff on this site but my input file is different

  • 0

I found some helpful stuff on this site but my input file is different from the examples already posted and I cannot make the leap in an efficient manner.

My input file looks like this:

sample_dude data1 data2 data3 data4
sample_lady data5 data6 data7 data8
sample_dude data9 data10 data11 data12
sample_child data13 data14 data15 data16

I want to create a separate file for each sample with all the data columns. For example, one file would be called sample_dude.txt and look like this:

data1 data2 data3 data4
data9 data10 data11 data12

There is an unknown number of samples but always just four data columns.

Any help greatly appreciated. Thank you.

PS: I’m trying to do this in python.

  • 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-06-14T09:00:29+00:00Added an answer on June 14, 2026 at 9:00 am

    For example like this:

    with open('input.txt') as input:
        for line in input:
            name, data = line.split(' ', 1)
    
            with open('{0}.txt'.format(name), 'a') as f:
                f.write(data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Already found this page with some helpful hints. Problem is I need to debug
Have done some research and found some stuff that may be helpful. I would
I've searched over this topic but found very few details which were helpful. With
I have found some useful info on this issue but can't quite wrap my
I have found some threads on this but they are three years old. Does
I implemented some code using backbone.js in Asp.NEt MVC3 and found backbone.js very helpful.
I found some classes designed for debugging in package com.sun.jdi like VirtualMachine , but
I found some really great code from Matt Gallagher for use with making Undo
I found some sample is teach you how to draw on iphone but it
I found some manual here : http://support.microsoft.com/kb/316898/ru but can't make a step with :

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.