0

I'm trying to import data (csv type) with Spyder (it has an Import Data option-green arrow, do you know what is this command by default?) and I get this error: 'NoneType' object has no attribute 'send'

Also, I have tried with numpy.genfromtxt("file.csv", delimiter = ',') and numpy.loadtxt("file.csv", delimiter = ',') but don't work. I am working with Python 3.2.3 and I use numpy and scipy (imported before execute the previuos commands).

Example of my datafile:

TIMESTAMP,TIMESTAMP,TIMESTAMP,TIMESTAMP,RECORD,Net_Shortwave_Avg (Wm-2),Net_Longwave_Avg(Wm-2),Net_Rad_Avg(Wm-2 )
12/21/2012 11:00:00,1100,12,11,0,556.0623,-131.1266,424.9357
12/21/2012 11:01:00,1101,12,11,1,564.877,-132.1396,432.7373
6
  • We need more info, you have to upload your code. Commented Sep 4, 2013 at 20:34
  • I don't have a code yet because I need to import the data first and I have tried with the above commands, numpy.genfromtxt and numpy.loadtxt Commented Sep 4, 2013 at 20:37
  • Whats send? And what is the NoneType object? Commented Sep 4, 2013 at 20:39
  • I don't know, that message just appear when I'm trying to import the data with the Import Data option of Spyder Commented Sep 4, 2013 at 20:43
  • Can you post a sample of your datafile? Then we can figure out why loadtxt doesn't work. It should work for a simple csv file. Commented Sep 4, 2013 at 22:48

1 Answer 1

1

The loadtxt function, by default, tries to convert everything to a float. It is getting confused by the text in the header and the datetime objects in the first column. You can tell it how to use the datetime objects, and you can also have it read the header. However, the simplest thing to do is to tell loadtxt to ignore the first row and the first column, like this:

data = np.loadtxt('data.csv',delimiter=',',usecols=range(1,7),skiprows=1)

It might also be convenient to unpack you data into separate variables, like this (I'm kinda guessing what some of the fields are):

day,hour,minute,Net_Shortwave_Avg,Net_Longwave_Avg,Net_Rad_Avg =  np.loadtxt('data.csv',delimiter=',',usecols=range(1,7),skiprows=1,unpack=True)
Sign up to request clarification or add additional context in comments.

Comments

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.