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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:16:16+00:00 2026-06-09T13:16:16+00:00

I have a large text file with words that are interspersed with numbers and

  • 0

I have a large text file with words that are interspersed with numbers and two types of characters, a '|' and '.'. I searched on StackOverflow and found how to take this string and only retain letters. For example, if

old_fruits='apple|0.00|kiwi|0.00|0.5369|-0.2437|banana|0.00|pear'

then

re.sub("[^A-Za-z]","",old_fruits)

would return

'applekiwibananapear'

I’m trying to write these words out to a file with one word on each line, followed by a newline and then the next word, like:

apple
kiwi
banana
pear

Any thoughts or pointing in the right direction is appreciated.

  • 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-09T13:16:17+00:00Added an answer on June 9, 2026 at 1:16 pm

    Try this:

    import re
    
    old_fruits = 'apple|0.00|kiwi|0.00|0.5369|-0.2437|banana|0.00|pear'
    
    with open('fruits.out', 'w') as f:
        fruits = re.findall(r'[^\W\d]+', old_fruits)
        f.write('\n'.join(fruits))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large text file that has a lot of special characters in
Okay, basically, I have a large list of phone numbers in a text file
i have large numbers of text files and i am in problem that i
I have two large (~100 GB) text files that must be iterated through simultaneously.
I have a text file that is almost sometimes 5 mb large. What I
I have a large text file (~10mb) that has more or less every dictionary
I have a large text file that has the following headings that I'm trying
I have a function that reads a text file containing two lines, it reads
I have two very large(30000+ documents) collections, one contains words extracted from a text
I have a large file that is full of text lines that I want

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.