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.9k views
in Technique[技术] by (71.8m points)

使用 loadTextEx载入csv格式文件时报错:中文列名不存在

导入列名为中文的tick数据时,发生以下错误,求各位前辈指点
dbDate = database("", VALUE, 2011.01.01..2020.12.31)
dbSymbol=database("", HASH, [DATE,10])
db = database("dfs://level2_2", COMPO, [dbDate, dbSymbol])

dataDir="D:/data/jsydata_unrar/tick/20130107/"

def importTxtFiles(dataDir, db){

dataFiles = exec filename from files(dataDir)
for(f in dataFiles){
    loadTextEx(db, `quotes,`证券代码`时间, dataDir + f)
}

}
importTxtFiles(dataDir, db);

importTxtFiles(dataDir, db) => importTxtFiles: loadTextEx(db, "quotes", ["证券代码","时间"], dataDir + f) => The partition column [证券代码] doesn't exist.

以下是csv文件字段名:
csv文件


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

1 Reply

0 votes
by (71.8m points)

这个应该是csv文件的编码不是utf8造成的,DolphinDB支持utf8,可以在GUI中执行

extractTextSchema(fileName)

确认一下是否显示乱码。若显示乱码,csv就不是utf8。

若只是列名不是utf8,可以按下面例子转换:

schema1=extractTextSchema(fileName)
update schema1 set name=convertEncode(name,"gbk","utf-8") 
t1=ploadText(fileName,,schema1)

若值也有中文,可以参考下面教程6.1节进行转换:
https://gitee.com/dolphindb/T...


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

...