尝试将数据集作为中的表加载时出错快照.py

2024-06-28 11:28:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我想装co04_dist.txt文件从http://people.sc.fsu.edu/~jburkardt/datasets/cities/cities.html作为表快照.py你知道吗

import snap

context = snap.TTableContext()
filename = "co04_dist.txt"

schema = snap.Schema()
schema.Add(snap.TStrTAttrPr("Col1", snap.atInt))
schema.Add(snap.TStrTAttrPr("Col2", snap.atInt))
schema.Add(snap.TStrTAttrPr("Col3", snap.atInt))
schema.Add(snap.TStrTAttrPr("Col4", snap.atInt))

table = snap.TTable.LoadSS(schema, filename, context, "\t", snap.TBool(False))

但我得到的只是运行时错误,声称应用程序请求运行时以一种不寻常的方式终止它。外壳上也写着:

Traceback (most recent call last):
  File "C:\Users\User\Documents\city.py", line 12, in <module>
table = snap.TTable.LoadSS(schema, filename, context, "\t", snap.TBool(False))
  File "C:\Python27\lib\snap.py", line 23070, in LoadSS
return _snap.TTable_LoadSS(*args)
RuntimeError: Execution stopped: Ss.GetFlds() == S.Len(), file c:\cygwin\home\rok\build\snap\snap-core\table.cpp, line 683

我已经确保txt文件已经与.py文件位于同一目录中。你知道吗


Tags: 文件pytxtaddschemacontextlinetable