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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:39:42+00:00 2026-06-14T19:39:42+00:00

I am trying to output a 4D numpy float array to a plaintext file

  • 0

I am trying to output a 4D numpy float array to a plaintext file using numpy.savetxt

However numpy gives an error saying that a float argument is required when I try to pass this array. Nevertheless the numpy doc specifies that the argument to be passed should just be array like… NOT that it should be of max rank 2. The only way I can make it work is by reshaping the data to 2D (and this is actually not always practical for data organisation reasons)

Is there way around this? Or must one necessarily reshape the numpy array to 2D?
I was expecting to be able to read the data in fortran like column-by-column style (working up through the dimensions).

Are there other possibilities? Note that I do not want to use the npy format since I seek compatibility with another program which needs plaintext format.

  • 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-14T19:39:43+00:00Added an answer on June 14, 2026 at 7:39 pm

    A different approach is to save the array as a simple list of numbers (the flat version of the array) and save along it the information about its shape.

    The problem about multidimensional arrays is that it’s not that simple to move them from program to program even in text format.

    you can do something like this:

    myarray = rand(5,5,5)
    name = 'myarray'+myarray.shape+'.txt'
    np.savetxt(name,myarray.flatten())
    

    and use the information on the size inclued in the filename to restore the initial shape

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

Sidebar

Related Questions

I'm trying to slice a numpy array using a slice that is predefined in
I am trying to output POST-data that I send from an android phone, however
I was trying to output a not null terminated char array to a file.
I am trying to output dates in the Italian format using date() as follows:
I'm trying to output unicode string into RTF format. (using c# and winforms) From
I am trying to output a file in perl. I open the file and
I want to create an array in numpy that contains the values of a
I am trying to output results using the geoNear command using PHP but what
I'm trying to output a xml file without xml head like I tried: Type
I'm using numpy 1.6 and matplotlib 1.1.1, trying to generate a velocity field from

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.