1

So I am trying to upload the file http://www.ice.csic.es/personal/aldos/Solar_Data_files/nudistr_b16_agss09.dat
into my code.

data= np.genfromtxt('nudistr_b16_agss09.csv',delimiter=',',skip_header=21)
t=data[:,1]  #temperature (10^6 K)
r=data[:,0]    #radius (units of one solar radius)
ne=data[:,2]   #Log base 10 of electron density (cm^{-3}/N_A,N_A is Avogadro number)

However I keep getting the error too many indices for array. I do not understand because I have used this format before and have not run into errors such as these before. What can I do to change it?

1
  • 1
    Try print(data.shape) on the second line to see if the dimensions of data match what you are expecting Commented Nov 24, 2017 at 0:09

1 Answer 1

1

It looks like your data file uses newlines (not commas) as delimiters. Try removing the delimiter argument:

data= np.genfromtxt('nudistr_b16_agss09.dat',skip_header=21)
Sign up to request clarification or add additional context in comments.

2 Comments

That seemed to resolve the issue, thank you so much!!
You're welcome! Please accept my answer if it solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.