using XLSX
Cs=XLSX.readdata("E:\\Julia程序\\Cs.xlsx","Sheet1","A1:C24")
The above is my code for importing xlsx file (), which is the data type of array (any, 2) and cannot be directly operated with matrix. How can I import a file to make it a data type that can be operated with matrix? For example, float64etc.
in addition,I try to use the file converted to CSV format and then import it. Although a float file will be generated, there will be a warning
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
┌ Warning: `CSV.read(input; kw...)` is deprecated in favor of `DataFrame!(CSV.File(input; kw...))`
└ @ CSV C:\Users\61940\.juliapro\JuliaPro_v1.4.2-1\packages\CSV\hZ1pV\src\CSV.jl:40
sorry,I didn’t really understand the meaning of it. I tried to modify it, but I still reported an error
ERROR: LoadError: UndefVarError: DataFrame! not defined
Stacktrace:
[1] top-level scope at untitled-00d5839736e1528ded8439f9249e3ead:6
in expression starting at untitled-00d5839736e1528ded8439f9249e3ead:6
You can abbreviate the second line to Matrix(PHL). Also note that convention in Julia is to use lowercase identifiers for variables, and uppercase identifiers for types (like DataFrame).
First of all, thank you for your correction!
After I use matrix (PHL), the generated data frame type cannot be used for matrix operation or multiplication and division with integers. It seems that I need float type.
What do you mean by “data frame type” after you used Matrix? If your csv is as shown in your first post (i.e. a bunch of floating point numbers like 0.43 0.82, 1.02) then you’ll get an Array{Float64, 2} back from doing Matrix{PHL}.
This array can then be used for the usual mathematical operations in Julia:
using XLSX
using CSV ,DataFrames
Cs=XLSX.readdata("E:\\Julia程序\\Cs.xlsx","Sheet1","A1:C24")
Cs=convert(Array{Float64,2}, Cs)
PHL=DataFrame(CSV.File("E:\\Julia程序\\PHL.csv"))
Matrix(PHL)
This is my code. After I use matrix (PHL), it is still a dataframe file. It seems a little strange
Matrix() does not operate in place. Again as a convention, functions that do operate in place or change their arguments are denoted by an ! at the end (this is just a naming convention, so you couldn’t just add a ! to some function to make it in-place).
You need to do
PHL = Matrix(PHL)
as in my example above.
I would encourage you to read the Julia documentation to familiarise yourself with the basics of the language.