Beginner: LoadError: InexactError: trunc..when convert dataframe

I use

using DataFrames, CSV

huhu=convert(DataFrame,dbtip)

when the DataFrame has about 10000 rows I am getting the message

LoadError: InexactError: trunc(Int8, 128)
in expression starting at /home/jiricvrk/Julia/tipy.jl:20

but the file created with the next instruction
CSV.write(“dbtip.csv”, huhu, delim = ‘;’)
is completed. When I use smaller dataframe there is no problem.

The problematic instruction is on line 65, but the listing means line 20 at first.
Please how do you recommend to modify my convert instruction?

I am using Julia 1.0.2 (previous 1.0.1) with Atom on Ubuntu 18.10.

Thank you very much for any help. And please excuse my English ;).

Regards, Jiri Cvrk

The full listing of an error follows:
LoadError: InexactError: trunc(Int8, 128)

in expression starting at /home/jiricvrk/Julia/tipy.jl:20

throw_inexacterror(::Symbol, ::Any, ::Int64) at boot.jl:567

checked_trunc_sint at boot.jl:589 [inlined]

toInt8 at boot.jl:604 [inlined]

Type at boot.jl:714 [inlined]

convert at number.jl:7 [inlined]

setindex!(::Array{Int8,2}, ::Int64, ::Int64, ::Int64) at array.jl:771

top-level scope at tipy.jl:52

include_string(::Module, ::String, ::String) at loading.jl:1008

(::getfield(Atom, Symbol(“##129#135”)){String,String,Module})() at eval.jl:125

withpath(::getfield(Atom, Symbol(“##129#135”)){String,String,Module}, ::String) at utils.jl:30

withpath at eval.jl:46 [inlined]

#128 at eval.jl:122 [inlined]

with_logstate(::getfield(Atom, Symbol(“##128#134”)){String,String,Module}, ::Base.CoreLogging.LogState) at logging.jl:395

with_logger at logging.jl:491 [inlined]

#127 at eval.jl:121 [inlined]

hideprompt(::getfield(Atom, Symbol(“##127#133”)){String,String,Module}) at repl.jl:85

macro expansion at eval.jl:120 [inlined]

(::getfield(Atom, Symbol(“##126#132”)){Dict{String,Any}})() at task.jl:85

Please read Please read: make it easier to help you, and try to produce an MWE (minimum working example) of your code, to make it easier for others to help you.

From what you posted it appears that your code is trying to convert the number 128 into an Int8 format, which is failing as Int8 only supports the range from -128 to 127 (see the docs here for more explanation of the different number types).

It is hard to say how you should modify your code without knowing what you are actually trying to do.

1 Like

Thank you very much for reply.
When I started to prepare sample, I found the error :slight_smile:

I have defined an array

dbtip = zeros(Int8,howm,11) #row length 11!!

that was the problem when I have more data…
I changed it to

dbtip = zeros(Int16,howm,11) #row length 11!!

and code is working. I would like define in following manner: first six elements in row INT8 and next 5 INT16 in the future. It should be possible, shouldn’t it?

Best regards…