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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:48:34+00:00 2026-05-15T22:48:34+00:00

I am trying to make a disorganized text file into a list suitable for

  • 0

I am trying to make a disorganized text file into a list suitable for use with another python program. The text file is a list of data seperated by a few spaces but not in standard columns or anything organized. The goal of this program is to read through the file using python and after each piece of data that I want there is a space, so I want to make a new line. The output should be a list of data with each term on one line. In addition there are some terms that I do not want. All the terms that I want start with “JJ”.

Here is what i have so far. Note this does not run yet. I am looking for help finishing this program that will select all the terms starting with JJ and make a new line at the space after the JJ term. Thanks Robert

datafile = open ('C:\\textfile.txt', 'r')

line_list = line.split(" ")
for x in line_list:
    if x.startswith("JJ") : print line_list

EDIT: So i want to open the file called textfile and have python keep only the lines of data that start with “JJ”. Additionaly I want each data to be on it’s own line, which is why I want to seperate them using the space after each ilne of data? Is that clearer?

  • 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-15T22:48:34+00:00Added an answer on May 15, 2026 at 10:48 pm

    lines = [item for item in open('C:\textfile.txt', 'r').read().split(' ') if item.startswith("JJ")]

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

Sidebar

Related Questions

Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to make a generic PL/SQL procedure to export data in specific XML format,
I'm trying to make a data bound column invisible after data binding, because it
I am trying to make a div, that when you click it turns into
I'm trying make my first python app. I want make simple email sender form.
I am working with nHibernate, and trying make sense of bag collections. My data
Im trying to make a file input field have the following extensions only .zip,
Trying to make a quick and dirty news system. Have a basic XML file.
Trying to make a make generic select control that I can dynamically add elements
Trying to make a web service call to an HTTPS endpoint in my Silverlight

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.