Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

从csv文件导入行情数据时,列名是乱码

我在DolphinDB GUI中用下面代码导入股票行情数据:

ploadText("D:\DolphinDB\Quote\000001_20120104.csv")

得到结果如下图,表头是乱码,应该怎么办?
image.png

在csv文件中实际是下面这样的:
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

由于DolphinDB的字符串采用UTF-8编码,若加载的文件不是UTF-8编码,需在导入后进行转化。DolphinDB提供了convertEncodefromUTF8toUTF8函数,用于导入数据后对字符串编码进行转换。加入csv是gbk编码,可以用如下代码对表头进行转换:

fileName="D:\DolphinDB\Quote\000001_20120104.csv"
schema1=extractTextSchema(fileName)
update schema1 set name=convertEncode(name,"gbk","utf-8") 
t=ploadText(fileName,,schema1)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...