# Julia数据处理常用包_DataFrames包测试3_2020-02-20Th
#@ 前面我们学习和测试了DataFrames包的特征和函数功能,下面我们接着本次的测试:利用DataFrames包读取.csv文件中的数据。
using DataFrames
using DelimitedFiles
using CSV
mycsv1 = open("mycsv_test.csv","w")
data1 = rand(1:1000,10,8)
println(data1)
# [974 379 630 665 371 733 164 377; 590 992 342 44 736 781 310 940; 120 364 988 837 642 230 225 609; 301 985 681 985 479 500 733 898; 115 295
# 629 170 202 364 622 718; 900 426 601 47 986 133 673 521; 686 411 31 809 606 199 726 413; 98 114 481 423 557 217 224 537; 406 656 149 682 94
# 554 186 271; 397 128 767 474 912 994 560 736]
writedlm(mycsv1,data1,',')
close(mycsv1)
println("已经成功创建csv文件,并且写入一个10行8列的数据矩阵。")
df = readtable("mycsv_test.csv")
#@ 如果不出意外,你会得到如下的报错信息:
# julia> df = readtable("mycsv_test.csv")
# ┌ Warning: readtable is deprecated, use CSV.read from the CSV package instead
# │ caller = top-level scope at none:0
# └ @ Core none:0
# ERROR: Invalid UTF-8 string
# Stacktrace:
# [1] utf8proc_error(::Int64) at .\strings\unicode.jl:142
# [2] utf8proc_map(::String, ::Int64) at .\strings\unicode.jl:147
# [3] #normalize#1 at .\strings\unicode.jl:197 [inlined]
# [4] normalize at .\strings\unicode.jl:176 [inlined]
# [5] #normalize#1 at C:\Users\julia\AppData\Local\Julia-1.2.0\share\julia\stdlib\v1.2\Unicode\src\Unicode.jl:56 [inlined]
# [6] normalize at C:\Users\julia\AppData\Local\Julia-1.2.0\share\julia\stdlib\v1.2\Unicode\src\Unicode.jl:56 [inlined]
# [7] identifier(::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:786
# [8] parsenames!(::Array{Symbol,1}, ::Bool, ::Array{UInt8,1}, ::Array{Int64,1}, ::BitArray{1}, ::Int64, ::Bool) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:852
# [9] readtable!(::DataFrames.ParsedCSV, ::IOStream, ::Int64, ::DataFrames.ParseOptions{String,String}) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:932
# [10] #readtable#379(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::IOStream, ::Int64) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1020
# [11] (::getfield(DataFrames, Symbol("#kw##readtable")))(::NamedTuple{(:header, :separator, :quotemark, :decimal, :nastrings, :truestrings,
# :falsestrings, :makefactors, :nrows, :names, :eltypes, :allowcomments, :commentmark, :ignorepadding, :skipstart, :skiprows, :skipblanks, :encoding, :allowescapes, :normalizenames),Tuple{Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}}, ::typeof(readtable), ::IOStream, ::Int64) at .\none:0
# [12] (::getfield(DataFrames, Symbol("#_r#381")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool})(::IOStream) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1102
# [13] #open#312(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(open), ::getfield(DataFrames, Symbol("#_r#381")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}, ::String, ::Vararg{String,N} where N) at .\iostream.jl:375
# [14] open at .\iostream.jl:373 [inlined]
# [15] #readtable#380(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1138
# [16] readtable(::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1099
# [17] top-level scope at none:0
#@ 我们再试
println("读取mycsv_test.csv文件数据,并用表格显示如下:", readtable("mycsv_test.csv"))
#@ 仍然报错,但是提示我们readtable()函数已经弃用
# ┌ Warning: readtable is deprecated, use CSV.read from the CSV package instead
# │ caller = top-level scope at none:0
# └ @ Core none:0
# ERROR: Invalid UTF-8 string
# Stacktrace:
# [1] utf8proc_error(::Int64) at .\strings\unicode.jl:142
# [2] utf8proc_map(::String, ::Int64) at .\strings\unicode.jl:147
# [3] #normalize#1 at .\strings\unicode.jl:197 [inlined]
# [4] normalize at .\strings\unicode.jl:176 [inlined]
# [5] #normalize#1 at C:\Users\julia\AppData\Local\Julia-1.2.0\share\julia\stdlib\v1.2\Unicode\src\Unicode.jl:56 [inlined]
# [6] normalize at C:\Users\julia\AppData\Local\Julia-1.2.0\share\julia\stdlib\v1.2\Unicode\src\Unicode.jl:56 [inlined]
# [7] identifier(::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:786
# [8] parsenames!(::Array{Symbol,1}, ::Bool, ::Array{UInt8,1}, ::Array{Int64,1}, ::BitArray{1}, ::Int64, ::Bool) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:852
# [9] readtable!(::DataFrames.ParsedCSV, ::IOStream, ::Int64, ::DataFrames.ParseOptions{String,String}) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:932
# [10] #readtable#379(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::IOStream, ::Int64) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1020
# [11] (::getfield(DataFrames, Symbol("#kw##readtable")))(::NamedTuple{(:header, :separator, :quotemark, :decimal, :nastrings, :truestrings,
# :falsestrings, :makefactors, :nrows, :names, :eltypes, :allowcomments, :commentmark, :ignorepadding, :skipstart, :skiprows, :skipblanks, :encoding, :allowescapes, :normalizenames),Tuple{Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}}, ::typeof(readtable), ::IOStream, ::Int64) at .\none:0
# [12] (::getfield(DataFrames, Symbol("#_r#381")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool})(::IOStream) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1102
# [13] #open#312(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(open), ::getfield(DataFrames, Symbol("#_r#381")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}, ::String, ::Vararg{String,N} where N) at .\iostream.jl:375
# [14] open at .\iostream.jl:373 [inlined]
# [15] #readtable#380(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1138
# [16] readtable(::String) at C:\Users\lenovo\.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\deprecated.jl:1099
# [17] top-level scope at none:0
#@ 我们用CSV包中的read()函数读取数据
df = read(mycsv1)
println("读取mycsv_test.csv文件中的数据,打印全部数据:")
dfnew = DataFrame(df)
println(dfnew)
#@ 或者写成一句
println("读取mycsv_test.csv文件数据,并用表格显示如下:", read("mycsv_test.csv"))
#@ 显示乱码如下:
# 取mycsv_test.csv文件数据,并用表格显示如下:UInt8[0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x02, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0xed, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x01,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0xc7, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xce, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x03, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0xbb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0xc1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xed, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x2b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x02, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xce,
# 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x74, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x02, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0xcd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x36, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xed, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x02, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x96, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x02, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xce, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x03, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x00,
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x37, 0x39, 0x30, 0x2c, 0x31,
# 0x37, 0x37, 0x2c, 0x34, 0x30, 0x36, 0x2c, 0x35, 0x35, 0x35, 0x2c, 0x32, 0x30, 0x34, 0x2c, 0x33, 0x37, 0x34, 0x2c, 0x35, 0x32, 0x30, 0x2c, 0x33, 0x33, 0x36, 0x0a, 0x33, 0x30, 0x33, 0x2c, 0x35, 0x30, 0x34, 0x2c, 0x39, 0x35, 0x32, 0x2c, 0x37, 0x31, 0x31, 0x2c, 0x32, 0x32, 0x30, 0x2c, 0x35, 0x36, 0x37, 0x2c, 0x38, 0x31, 0x32, 0x2c, 0x32, 0x37, 0x37, 0x0a, 0x38, 0x32, 0x32, 0x2c, 0x35, 0x33, 0x2c, 0x33, 0x35, 0x31, 0x2c,
# 0x31, 0x34, 0x37, 0x2c, 0x35, 0x34, 0x31, 0x2c, 0x36, 0x31, 0x34, 0x2c, 0x32, 0x35, 0x33, 0x2c, 0x34, 0x35, 0x32, 0x0a, 0x36, 0x37, 0x36, 0x3, 0x2c, 0x36, 0x0a, 0x36, 0x38, 0x35, 0x2c, 0x34, 0x38, 0x33, 0x2c, 0x37, 0x32, 0x38, 0x2c, 0x31, 0x38, 0x32, 0x2c, 0x33, 0x39, 0x31, 0x2c, 0x38, 0x32, 0x33, 0x2c, 0x37, 0x35, 0x36, 0x2c, 0x36, 0x32, 0x34, 0x0a, 0x34, 0x39, 0x33, 0x2c, 0x36, 0x31, 0x2c, 0x32, 0x37, 0x39, 0x2c, 0x32, 0x33, 0x35, 0x2c, 0x35, 0x39, 0x34, 0x2c, 0x36, 0x38, 0x31, 0x2c, 0x39, 0x37, 0x33, 0x2c, 0x37, 0x30, 0x35, 0x0a, 0x39, 0x36, 0x38, 0x2c, 0x37, 0x34, 0x37, 0x2c, 0x31, 0x34, 0x2c, 0x37, 0x33, 0x37, 0x2c, 0x31, 0x36, 0x39, 0x2c, 0x38, 0x38, 0x34, 0x2c, 0x35, 0x37, 0x32, 0x2c, 0x35, 0x36, 0x36, 0x0a, 0x35, 0x30, 0x37, 0x2c, 0x39, 0x33, 0x39, 0x2c, 0x36, 0x39, 0x36, 0x2c, 0x37, 0x39, 0x30, 0x2c, 0x34, 0x36, 0x32, 0x2c, 0x31, 0x30, 0x32, 0x2c, 0x37, 0x30, 0x30, 0x2c, 0x37, 0x30, 0x37, 0x0a, 0x33, 0x33, 0x30, 0x2c, 0x39, 0x30, 0x31, 0x2c, 0x31, 0x35, 0x32, 0x2c, 0x37, 0x31, 0x36, 0x2c, 0x39, 0x34, 0x30, 0x2c, 0x36, 0x34, 0x38, 0x2c, 0x31, 0x37, 0x36, 0x2c, 0x36, 0x34, 0x31, 0x0a, 0x32, 0x32, 0x30, 0x2c, 0x37, 0x35, 0x38, 0x2c, 0x37, 0x39, 0x36, 0x2c, 0x36, 0x34, 0x35, 0x2c, 0x36, 0x39, 0x39, 0x2c, 0x32, 0x36, 0x33, 0x2c, 0x37, 0x33, 0x33, 0x2c, 0x39, 0x38, 0x30, 0x0a]
#@ 总之不是我们想要的结果
using CSV
using DataFrames
mydata = CSV.read("mycsv_test.csv")
println("利用read()函数读取csv文件中的信息并显示:")
println(mydata)
# 利用read()函数读取csv文件中的信息并显示:
# 9×8 DataFrame
# │ Row │ 331 │ 68 │ 875 │ 304 │ 578 │ 16 │ 436 │ 376 │
# │ │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │
# │ 1 │ 202 │ 514 │ 656 │ 268 │ 849 │ 651 │ 455 │ 77 │
# │ 2 │ 888 │ 882 │ 39 │ 237 │ 995 │ 955 │ 591 │ 836 │
# │ 3 │ 383 │ 942 │ 201 │ 747 │ 935 │ 262 │ 78 │ 157 │
# │ 4 │ 479 │ 301 │ 588 │ 828 │ 101 │ 989 │ 26 │ 857 │
# │ 5 │ 724 │ 738 │ 201 │ 750 │ 741 │ 80 │ 481 │ 184 │
# │ 6 │ 299 │ 180 │ 582 │ 298 │ 266 │ 991 │ 271 │ 604 │
# │ 7 │ 955 │ 285 │ 549 │ 76 │ 505 │ 68 │ 11 │ 242 │
# │ 8 │ 24 │ 962 │ 219 │ 342 │ 745 │ 910 │ 453 │ 193 │
# │ 9 │ 432 │ 522 │ 981 │ 248 │ 282 │ 734 │ 667 │ 892 │
#@ 虽然已经很不错了,但是感觉这个表格还缺些什么,对,没有表头,感觉不完整,所以下面我们给表格数据添加表头
mydata = CSV.read("mycsv_test.csv";header=["第一列","第二列","第三列","第四列","第五列","第六列","第七列","第八列"])
println("添加好表头之后,我们再次打印mydata数据:")
println(mydata)
# 10×8 DataFrame
# │ Row │ 第一列 │ 第二列 │ 第三列 │ 第四列 │ 第五列 │ 第六列 │ 第七列 │ 第八列 │
# │ │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │
# ├─────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
# │ 2 │ 202 │ 514 │ 656 │ 268 │ 849 │ 651 │ 455 │ 77 │
# │ 3 │ 888 │ 882 │ 39 │ 237 │ 995 │ 955 │ 591 │ 836 │
# │ 4 │ 383 │ 942 │ 201 │ 747 │ 935 │ 262 │ 78 │ 157 │
# │ 5 │ 479 │ 301 │ 588 │ 828 │ 101 │ 989 │ 26 │ 857 │
# │ 6 │ 724 │ 738 │ 201 │ 750 │ 741 │ 80 │ 481 │ 184 │
# │ 7 │ 299 │ 180 │ 582 │ 298 │ 266 │ 991 │ 271 │ 604 │
# │ 8 │ 955 │ 285 │ 549 │ 76 │ 505 │ 68 │ 11 │ 242 │
# │ 9 │ 24 │ 962 │ 219 │ 342 │ 745 │ 910 │ 453 │ 193 │
# │ 10 │ 432 │ 522 │ 981 │ 248 │ 282 │ 734 │ 667 │ 892 │
#@ 那问题来了,如何修改行名呢?留给大家解决
#@ 你要注意你的思想,因为它会影响你的语言;你要注意你的语言,因为它会影响你的行为;你要注意你的行为,因为它会影响你的习惯;你要注意你的习惯,因为它会影响你的命运。