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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:48:24+00:00 2026-05-23T10:48:24+00:00

I have a file with many lines each having over 20 numerical values, e.g.:

  • 0

I have a file with many lines each having over 20 numerical values, e.g.:

123 1 18 180776 4303656 1605 16468 0 51429 24230 0 0 0 4 8 0 8710 14705 1836 1 4 95
0 24538 0 187860 4264028 449 4711 0 2537 2537 0 0 5 0 0 0 6138 12880 1590 1 22 76
...

I’d like to:

  1. read one line
  2. save it in some python data type (what would be the best ?)
  3. do some operations on each number taken from the above line, e.g.:
    • check if it is not above sth (and save the result)
    • check if it is not belowe sth (and save the result)
    • count its length (number of digits) (and save the result)
    • compare it to the previous number from the same column
    • –

So after a one line (with numbers) I should have:

  1. store each number
  2. store additional attributes for each number

Each number is compared to previous one from the same column, store the result but then I can forget the previous line.

What data type would be the best to store above data ?

  • 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-23T10:48:25+00:00Added an answer on May 23, 2026 at 10:48 am

    It’s hard to say which data type would be best without knowing what you’re gonna do with the aggregated information. However, a simple solution would be to use a list for each line, containing 2-tuples with the actual number and a dictionary with attributes:

    line = [(1, {'even': False, 'foo': 'bar'}), ..., (2332, {'even': True, 'foo': 'baz'}), ...]
    

    Here’s how to get this list starting from a line of text:

    line = "4 0 2837 9323 ..."
    line = [(int(n), dict()) for n in line.split()]
    

    Then iterate the list and set attributes:

    for n, attributes in line:
        ...
        attributes['foo'] = 'bar'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test file that has many lines, each line looks something like:
I have a plain text file with many lines. Each line contains 5 words
I have a CSV file. It has many lines. In each line there are
I have a file with many lines in it. One of them look like
I have a file that is similar to this: <many lines of stuff> SUMMARY:
I have a program in which each thread reads in files many lines at
I want to know how many lines I have in my file. How can
I have a txt file with 16 lines of integers. Each line contains 5
I have a large file, 100,000 lines. I can read each line and process
I have a text file of about 20 million lines. Each line is 25

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.