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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:34:22+00:00 2026-06-18T11:34:22+00:00

I am fairly new to Python, but I would like to get started and

  • 0

I am fairly new to Python, but I would like to get started and learn a bit by doing some scripting for features I will use. I have some text that is retrieved from typing in “status” in Team Fortress 2’s console. What I would like to achieve is, I want to convert this text below into text where there is only the STEAM_X:X:XXXXXXXX which is the Steam64 ID.

# userid name                uniqueid            connected ping loss state
#     31 "Atonement -Ai-"    STEAM_0:1:27464943  00:48      103    0 active
#     10 "?loop?"        STEAM_0:0:31072991  40:48       62    0 active
#     11 "爱 -Ai-"          STEAM_0:0:41992530  40:46       68    0 active
#     12 "MrKateUpton -Ai-"  STEAM_0:1:10894538  40:25       81    0 active
#     13 "Tacet -Ai-"        STEAM_0:1:52131782  39:59       83    0 active
#     14 "CottonBonbon-Ai-"  STEAM_0:1:47812003  39:39       51    0 active
#     15 "belt -Ai-"         STEAM_0:1:4941202   38:43      123    0 active
#     16 "boutros :3"        STEAM_0:0:32271324  38:21       65    0 active
#     17 "[tilt] Xikkari"    STEAM_0:1:41148798  38:14       92    0 active
#     24 "ElenaWitch"        STEAM_0:0:17495028  31:30       73    0 active
#     19 "[tilt] Batcan #boutros" STEAM_0:1:41205650 38:10   63    0 active
#     20 "[?l??]whatupmydiggas" STEAM_0:1:50559125 37:58  112    0 active
#     21 "[tilt] musicman"   STEAM_0:1:37758467  37:31       89    0 active
#     22 "Jack Frost"        STEAM_0:0:24206189  37:28       90    0 active
#     28 "[tilt-sub]deaf ears #best safet" STEAM_0:1:29612138 19:05   94    0 active
#     25 "? notez ?ai"    STEAM_0:1:29663879  31:23      113    0 active
#     27 "-Ai- Lord English" STEAM_0:1:44114633  24:08      116    0 active
#     29 "1.prototypes"      STEAM_0:0:42256202  17:41       83    0 active
#     30 "SourceTV  // name for SourceTV" BOT                        active
#     32 "PUT ME IN COACH"   STEAM_0:1:48004781  00:36      173    0 spawning

Is there any built-in functions in Python that does the following algorithm?

For all that is not (!) Steam_X:X:XXXXXXXX, delete/remove.

I have done a fair amount of Googling, but nothing really gets specific. If someone could get me started with a built-in Python function, I would be so grateful to start coding.

P.S. The output would be like this

STEAM_0:1:27464943
STEAM_0:0:31072991
STEAM_0:1:10894538
etc
etc
  • 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-18T11:34:23+00:00Added an answer on June 18, 2026 at 11:34 am

    Sounds like an easy case for a regex. Assuming they’re always digits like that:

    >>> import re
    
    >>> with open('/tmp/spam.txt') as f:
    ...   for steam64id in re.findall(r'STEAM_\d:\d:\d+', f.read()):
    ...     print steam64id
    ... 
    STEAM_0:1:27464943
    STEAM_0:0:31072991
    STEAM_0:0:41992530
    STEAM_0:1:10894538
    STEAM_0:1:52131782
    STEAM_0:1:47812003
    STEAM_0:1:4941202
    STEAM_0:0:32271324
    STEAM_0:1:41148798
    STEAM_0:0:17495028
    STEAM_0:1:41205650
    STEAM_0:1:50559125
    STEAM_0:1:37758467
    STEAM_0:0:24206189
    STEAM_0:1:29612138
    STEAM_0:1:29663879
    STEAM_0:1:44114633
    STEAM_0:0:42256202
    STEAM_0:1:48004781
    

    The usual recipe for removing lines is not to delete them from the original file, but print out the lines you want to keep to a new file (and then, optionally, copy it overwriting the original file, if the processing was successful).

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

Sidebar

Related Questions

So I am fairly new to python. But would like your help solving this
I'm currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I'm fairly new to Python, but
I'm fairly new to Python, so I'm trying my hand at some simple code.
I am fairly new to the world of Python. Have just read some documents
I'm fairly new to python (and completely new to Python OO), but I'm working
I'm fairly new to Google App Engine and Python, but I did just release
I'm fairly new to Python, and was wondering how would I be able to
I'm still fairly new to Python and I'm trying to get used to its
I believe this is trival but fairly new to Python. I am trying to
I'm fairly new to Python, and I've just started working with XML parsing. I

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.