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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:13:35+00:00 2026-05-11T16:13:35+00:00

I have some data that I have stored in a list and if I

  • 0

I have some data that I have stored in a list and if I print out the list I see the following:

.
.
.
007 A000000 Y
007 B000000  5
007 C010100  1
007 C020100 ACORN FUND
007 C030100 N
007 C010200  2
007 C020200 ACORN INTERNATIONAL
007 C030200 N
007 C010300  3
007 C020300 ACORN USA
007 C030300 N
007 C010400  4
.
.
.

The dots before and after the sequence are to represent that there is other data that is similarily structured but might or might not not be part of this seventh item (007). if the first value in the seventh item is ‘007 A000000 Y’ then I want to create a dictionary listing of some of the data items. I can do this and have done so by just running through all of the items in my list and comparing their values to some test values for the variables. For instance a line of code like:

if dataLine.find('007 B')==0:
    numberOfSeries=int(dataLine.split()[2])

What I want to do though is

if dataLine.find(''007 A000000 Y')==0:
    READ THE NEXT LINE RIGHT HERE

Right now I am having to iterate through the entire list for each cycle

I want to shorten the processing because I have about 60K files that have between 500 to 5,000 lines in each.

I have thought about creating another reference to the list and counting the datalines until dataLine.find(”007 A000000 Y’)==0. But that does not seem like it is the most elegant solution.

  • 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-11T16:13:36+00:00Added an answer on May 11, 2026 at 4:13 pm

    Okay-while I was Googling to make sure I had covered my bases I came across a solution:

    I find that I forget to think in Lists and Dictionaries even though I use them. Python has some powerful tools to work with these types to speed your ability to manipulate them.
    I need a slice so the slice references are easily obtained by

    beginPosit = tempans.index('007 A000000 Y')
    endPosit = min([i for i, item in enumerate(tempans) if '008 ' in item])
    

    where tempans is the datalist
    now I can write

    for line in tempans[beginPosit:endPosit]:
        process each line
    

    I think I answered my own question. I learned alot from the other answers and appreciate them but I think this is what I needed

    Okay I am going to further edit my answer. I have learned a lot here but some of this stuff is over my head still and I want to get some code written while I am learning more about this fantastic tool.

    from itertools import takewhile
    beginPosit = tempans.index('007 A000000 Y')
    new=takewhile(lambda x: '007 ' in x, tempans[beginPosit:])
    

    This is based on an earlier answer to a similar question and Steven Huwig’s answer

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

Sidebar

Related Questions

I have some data that is stored in a TIMESTAMP(6) WITH TIMEZONE column in
I have a stored procedure that logs some data, how can I call this
I have an application that extracts data from some xml that is stored in
I have a table from a vendor application that stores some xml data into
We have a set of tables and views that merely store some config data
I have some data that won't printf.... echo works, but not printf There is
I have some data that I would like to visualize. Each byte of the
I have some data that I am displaying in 3 column format, of the
I have some data that has various attributes and I want to hierarchically group
I have some data that looks something like this... +----------+----------+----------+ | Column 1 |

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.