I think that means you are reading an area where there is an empty cell in the 
first row of the range. The first row is used for the column names of the 
DataFrame, and so it can’t have an empty cell in it.

 

Two possible ways out:

-           Make sure there are no empty cells in the first row of the range 
you are reading.

-           Change the range you read to A2:C1885, and then manually provide 
the names for the columns. Either by passing an array of symbols as colnames, 
or by passing header=false (in which case you will get auto created colnames)

 

Best,

David

 

 

From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On 
Behalf Of Brandon Booth
Sent: Wednesday, May 20, 2015 10:12 AM
To: julia-users@googlegroups.com
Subject: Re: [julia-users] Convert DataArray to DataFrame

 

So I tried it this morning and it works for several sheets, but not for one. 

When I run this:

f = openxl("Data.XLSX")

test = readxl(DataFrame, f, "Data!A1:C1885")


I get the following error:



NAException("Cannot convert DataArray with NA's to desired type")
while loading In[3], in expression starting on line 2
 
 in convert at C:\.julia\v0.3\DataArrays\src\dataarray.jl:561
 in readxl_internal at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:214
 in readxl at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:204


Any suggestions?

 

Thanks.

 

Brandon


On Tuesday, May 19, 2015 at 7:28:59 PM UTC-4, David Anthoff wrote:

Have you tried

 

df = readxl(DataFrame, "Filename.xlsx", "Sheet1!A1:C4")

 

That would return a DataFrame. Note that there is no readxlsheet that reads 
into a DataFrame (yet).

 

The eventual API design I had in mind is that one can pass as a first argument 
the return type one desires. Right now the only option is DataFrame, otherwise 
it defaults to a DataArray.

 

Cheers,

David 

 

From: julia...@googlegroups.com <javascript:>  
[mailto:julia...@googlegroups.com <javascript:> ] On Behalf Of Brandon Booth
Sent: Tuesday, May 19, 2015 7:22 PM
To: julia...@googlegroups.com <javascript:> 
Subject: [julia-users] Convert DataArray to DataFrame

 

I feel like this should be simple to do, but I can't seem to do it. I'm using 
ExcelReaders and it imports as a DataArray whereas I'd like to have the data as 
a DataFrame. I didn't see anything in the approximately 375 pages of methods 
for convert.

Thanks.

Brandon

Reply via email to