Ok,
I got it! It is just a matter of converting array to an element
read(fid, reshape(T[1])[1] ,keyNumElem[1])...
Now it works but I have a follow on question.
What are the overheads in doing this conversion. I am reading a 2Terabyte
data file....and want to make it really efficient by defining all
parameters in read() without dynamic
conversions if possible!
Or is there a way to replace the column of strings with Types? When I try
to do that I get an error about convert i.e. cannot convert string to
DataType...
Thanks
On Sunday, November 29, 2015 at 10:24:46 PM UTC-5, Rajn wrote:
>
> Hi,
> I am trying to read a binary file by doing the following:
>
> read(fid, DataType[i], Numelements[i]).
>
> I would like to extract DataType from a user input which is read from a
> column (whose header is 'type') of DataTable which is a string array.
> For example
> DataTable[1,:type] = "uint8"
> DataTable[2,:type] = "sint16"
> ..etc
> I would like to convert this "uint8" to UInt8 in that same column but I
> could not figure how and so I generated a new cell array' T' of that size.
> And then with an if statement I occupy the new variable with DataType.
> Ugh!!
>
> An example for an arbitrary kth row of the DataTable column...
>
> i.e., if DataTable[k,:type] == "int16"
> T[k]=Type[Int16];
> end
>
> when I actually run it I get the following error...
>
> julia> T[1]
> 1-element Array{DataType,1}:
> Int16
>
> julia>read(fid, T[1] ,keyNumElem[1])
>
> ERROR: MethodError: `read` has no method matching read(::IOStream,
> ::Array{Type{T},1}, ::Int32)
> Closest candidates are:
> read{T}(::IO, ::Type{T}, ::Int32, ::Int32...)
> read{T}(::IO, ::Type{T}, ::Integer, ::Integer...)
> read{T<:Base.AbstractPipe}(::T<:Base.AbstractPipe, ::Any...)
> ...
>
>
> I understand the problem but do not know how to convert a string to
> ..."what?" I mean what is the 'type' of the 2nd parameter in read
> -'Type{T}'? Is it a string?
> Or maybe I am correct and I have to convert Array to an element? How do I
> do that?
> Very confused!!
> Thanks
>
>