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 8285025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:19:27+00:00 2026-06-08T11:19:27+00:00

I have some large data files and I want to copy out certain pieces

  • 0

I have some large data files and I want to copy out certain pieces of data on each line, basically an ID code. The ID code has a | on one side and a space on the other. I was wondering would it be possible to pull out just the ID. Also I have two data files, one has 4 ID codes per line and the other has 23 per line.

At the moment I’m thinking something like copying each line from the data file, then subtract the strings from each other to get the desired ID code, but surely there must be an easier way! Help?

Here is an example of a line from the data file that I’m working with

cluster8032:  WoodR1|Wood_4286 Q8R1|EIK58010 F113|AEV64487.1 NFM421|PSEBR_a4327

and from this line I would want to output on separate lines

Wood_4286
EIK58010
AEV644870.1
PSEBR_a4327
  • 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-08T11:19:28+00:00Added an answer on June 8, 2026 at 11:19 am

    Use the regex module for such a task. The following code shows you how to extract the ID’s from a string (works for any number of ID’s as long as they are structured the same way).

    import re
    s = """cluster8032:  WoodR1|Wood_4286 Q8R1|EIK58010 F113|AEV64487.1 NFM421|PSEBR_a4327"""
    results = re.findall('\|([^ ]*)',s) #list of ids that have been extracted from string
    print('\n'.join(results)) #pretty output
    

    Output:

    Wood_4286
    EIK58010
    AEV64487.1
    PSEBR_a4327
    

    To write the output to a file:

    with open('out.txt', mode = 'w') as filehandle:
        filehandle.write('\n'.join(results))
    

    For more information, see the regex module documentation.

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

Sidebar

Related Questions

I have some large chunk of data that I want to send to the
I have two large source trees. One of them has some out of date
I have a python module which generates large data files which I want to
I have a large data.frame displaying some weird properties when plotted. I'd like to
I have an application on the Compact Framework that has some large embedded resources
I need to pre-compress some very large html/xml/json files (large data dumps) using either
I'm downloading some files asynchronously into a large byte array, and I have a
I have some large tables (millions of rows). I constantly receive files containing new
I'am programing in C language. Sometimes we have to read large data from files
I have a large set of files for which some heavy processing needs to

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.