【发布时间】:2022-01-19 23:58:26
【问题描述】:
我正在阅读 https://github.com/VinitaSilaparasetty/julia-beginners/blob/master/data/nba/nba19-20.csv 的 csv 文件
我得到一个 DataFrame 并将其保存为 XLSX。当我尝试在 jupyterlab 中读取它时,我收到错误 the file is not UTF-8 encoded,因此该文件未被读取。
这是我的代码:
using HTTP, XLSX, CSV, DataFrames
df = CSV.read(HTTP.get("https://raw.githubusercontent.com/VinitaSilaparasetty/julia-beginners/master/data/nba/nba19-20.csv").body)
# first(df,5) # first shows the top five rows ok
XLSX.writetable("data/nba/nba19-20.XLSX", collect(eachcol(df)), names(df), overwrite = true)
文件保存在我的数据文件夹中。当我尝试使用 jupyterlab 打开它时,我会弹出 file is not UTF-8 encoded 并且文件未打开。
当我尝试在 Ubuntu(使用 LibreOffice)中打开文件时,我没有看到任何可疑之处。
由于我是 Julia 新手,我很难理解问题出在哪里或如何解决。
我尝试查看是否可以使用 UTF-8 编码数据帧(将文件保存到磁盘后)
data = DataFrame(CSV.File(open(read,"data/nba/nba19-20.csv", enc"utf-8")))
但我没有看到任何变化。欢迎提出任何建议。
【问题讨论】:
标签: dataframe utf-8 julia xlsx jupyter-lab