读取txt数据文件时出错

2024-10-03 02:36:09 发布

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

这是我正在使用的代码,出于某种原因它不起作用。请帮帮我

我已经创建了一个包含一些数据的文本文件,当我尝试使用Pandas读取数据时,它不起作用

dF = pd.read_csv("PandasLongSample.txt", delimiter='/t')
print(dF)

这就是错误:

C:\Users\SVISHWANATH\AppData\Local\Continuum\anaconda3\lib\site-packages\ipykernel_launcher.py:1: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
  """Entry point for launching an IPython kernel.

谢谢你的帮助


Tags: csvthe数据代码pandasdfread读取数据
2条回答

使用反斜杠(\)而不是斜杠(/)作为制表符分隔符

dF = pd.read_csv("PandasLongSample.txt", delimiter='\t')
print(dF)

您的代码中有一个输入错误,它应该是\t,而不是/t

相关问题 更多 >