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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:00:15+00:00 2026-05-15T05:00:15+00:00

I am very new to Python, I need to read numbers from a file

  • 0

I am very new to Python, I need to read numbers from a file and store them in a matrix like I would do it in fortran or C;

for i
  for j
    data[i][j][0]=read(0)
    data[i][j][1]=read(1)
    data[i][j][2]=read(2)
...
...

How can I do the same in Python? I read a bit but got confused with tuples and similar things

If you could point me to a similar example it would be great

thanks

  • 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-15T05:00:16+00:00Added an answer on May 15, 2026 at 5:00 am

    Python doesn’t come with multi-dimensional arrays, though you can add them through the popular numpy third-party package. If you want to avoid third-party packages, what you would do in Python would be to use a list of lists of lists (each "list" being a 1-D "vector-like" sequence, which can hold items of any type).

    For example:

    data = [ [ [0 for i in range(4)] for j in range(5)] for k in range(6)]
    

    this makes a list of 6 items which are lists of 5 items which are lists of 4 0’s — i.e., a 6 x 5 x 4 "3D matrix" which you could then address the way you want,

    for i in range(6):
      for j in range(5):
        data[i][j][0]=read(0)
        data[i][j][1]=read(1)
        data[i][j][2]=read(2)
    

    to initialize the first three of the four items on each most-nested sublist with calls to that mysterious function read which presumably you want to write yourself (I have no idea what it’s supposed to do — not "read and return the next number" since it takes a mysterious argument, but, then what?).

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

Sidebar

Related Questions

I'm very new to Python, but I need to migrate a project from PHP
I am very new to Python. I need to have a 3 dimensional matrix,
I am very new to Python. I need to run diff.py(a python in built
I need to read and plot data in real time from multiple Android phones
I am very new to python. I need to draw this shape for college
I'm very new to python and I need to parse some dirty xml files
I'm very new to python. I need a simple and clear script to add
I was writing a simple python script to read from and reconstruct data from
I am still very new to python, but I need to interface with some
I am very new to matlab and python and need to use some values

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.