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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:53:52+00:00 2026-06-15T06:53:52+00:00

Lets say I have a data file that has this inside it: 23 33

  • 0

Lets say I have a data file that has this inside it:

23 33 45
91 81 414
28 0 4 
7 9 14
8 9 17
1 1 3
38 19 84

How can I import it into a list so that each individual number it its own item?

  • 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-15T06:53:53+00:00Added an answer on June 15, 2026 at 6:53 am

    You could alternatively use the python builtin functions like open file, split and readlines

    with open('file.txt') as f:
    for line in f:
      a, b, c = map(int, line.split())
    

    Another approach is

     file                = open(filename)
     file_data           = file.readlines()
    

    But, the output will be a list of strings.
    That is the each element in the list will represent one line in the file.
    If you use the above code the output will look like

     file_data = ['23 33 45', '91 81 414', '28 0 4 ', '7 9 14', '8 9 17', '1 1 3', '38 19 84']
    

    You might want them to convert to either float or int.
    you could do that using again numpy’s fromstring module

      from numpy import fromstring
      data = [fromstring(i, dtype=float, sep=' ') for i in file_data ]
    

    Notice that, I have used a list comprehension in the above code(which is faster than the conventional python for loop.)

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

Sidebar

Related Questions

Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
So, I have this file that has data set up like this: Bob 5
I have a data object (let's say it's called 'Entry') that has a set
Let’s say I have table/list like this n=3 in this case, but n can
Let's say we have a Windows app that has a TreeView and you can
This is the link I have that contains a big list of data which
Lets say I have data in two tables. In one I have Order ID
Lets say i have a table with the following data Customer table: Name amount
Lets say I have 2 columns in my data Grid: Column A: Selected, and
Lets say we have a table here, populated with the following data: acc_id1 acc_id2

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.