Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的.txt文件作为一列(而不是三列)读入我的笔记本_Python_Pandas_Dataframe_Text Files - Fatal编程技术网

Python 我的.txt文件作为一列(而不是三列)读入我的笔记本

Python 我的.txt文件作为一列(而不是三列)读入我的笔记本,python,pandas,dataframe,text-files,Python,Pandas,Dataframe,Text Files,我使用了下面的代码,但我必须删除原始.txt文件中的头才能工作 por_layer5 = pd.read_csv("Sample_File.txt",comment='#', header=None, delim_whitespace=True) 我想知道是否有办法读入.txt文件并设置只读入整数的条件,并将它们分成三列,而不必编辑原始的.txt文件。我提供了文件中包含标题的第一行的预览。我最初的想法是在数字开始时将文件索引为只读(其索引号为4),但我在这样做时遇到了麻烦

我使用了下面的代码,但我必须删除原始.txt文件中的头才能工作

por_layer5 =  pd.read_csv("Sample_File.txt",comment='#', header=None, delim_whitespace=True)
我想知道是否有办法读入.txt文件并设置只读入整数的条件,并将它们分成三列,而不必编辑原始的.txt文件。我提供了文件中包含标题的第一行的预览。我最初的想法是在数字开始时将文件索引为只读(其索引号为4),但我在这样做时遇到了麻烦


您可以在中使用
skiprows
选项

pd.read_csv("Sample_File.txt",comment='#', header=None, skiprows=4,delim_whitespace=True)