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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:09:55+00:00 2026-05-20T00:09:55+00:00

Suppose I have a text file that looks like this: 33 3 46 12

  • 0

Suppose I have a text file that looks like this:

33 3
46 12
23 10 23 11 23 12 23 13 23 14 23 15 23 16 24 10 24 11 24 12 24 13 24 14 24 15 24 16 25 14 25 15 25 16 26 16 27 16 28 16 29 16
33 17 33 18 33 19 34 17 34 18 34 19 35 17 35 18 35 19 36 19
41 32 41 33 42 32 42 33

I would like to read each line into a separate array of integers, as in (pseudo code):

for line in textfile:  
    currentArray = firstLine  
    do stuff with currentArray

where in the first iteration, currentArray would be

array([33, 3])

and in the second iteration, currentArray would be

array([46, 12])

until the last iteration, when currentArray would be

array([41, 32, 41, 33, 42, 32, 42, 33])

Basically, I would like to have the functionality of the numpy function loadtxt:

currentArray = loadtxt(‘scienceVertices.txt’, usecols=() )

Except instead of usecols, being able to specify the row, e.g.,

currentArray = loadtxt(‘scienceVertices.txt’, userows=(line) )

  • 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-20T00:09:56+00:00Added an answer on May 20, 2026 at 12:09 am

    Here’s a one-liner:

    arrays = [np.array(map(int, line.split())) for line in open('scienceVertices.txt')]
    

    arrays is a list of numpy arrays.

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

Sidebar

Related Questions

I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I run across this problem frequently suppose I have a text file that I
Suppose I have something like this: if ($command === 'txt') { header('Content-type: text/plain;charset=utf-8'); echo
Suppose I have 500 rows of data, each with a paragraph of text (like
I have an ActionMailer controller that's supposed to send this file: /user_mailer/welcome_email.text.erb This is
I have this code: File.foreach(testfile.txt) { |line| print line } lines = File.readlines(testfile.txt) lines.each
Suppose I have a tab delimited file containing user activity data formatted like this:
I have some HTML that looks like this: <h2>Heading</h2> <div class='myClass'> <h2>Another Heading</h2> </div>
Ok so basically I have this text file with numbers and letters that's supposed
Suppose you have a text file like: my_setting = ON some_method = METHOD_A verbosity

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.