Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.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 ParserError:标记数据时出错。C错误:从第行开始的字符串内的EOF_Python_Linux Df - Fatal编程技术网

Python ParserError:标记数据时出错。C错误:从第行开始的字符串内的EOF

Python ParserError:标记数据时出错。C错误:从第行开始的字符串内的EOF,python,linux-df,Python,Linux Df,我有大约58个数据源,我正试图找到它们,但收到了标题中的错误。 我在这方面做了很多研究,但从google/stackoverflow等的一些解决方案中仍然没有结果。 我正在做的是删除每个文件的前5行,在一个新列中使用文件名作为引用,然后将它们组合成一个数据帧,这样我就可以全面地查看数据 # Sets Parameters import os directory = 'C:\Test\TG' line_remove = 5 rename = 'File00' ex

我有大约58个数据源,我正试图找到它们,但收到了标题中的错误。 我在这方面做了很多研究,但从google/stackoverflow等的一些解决方案中仍然没有结果。 我正在做的是删除每个文件的前5行,在一个新列中使用文件名作为引用,然后将它们组合成一个数据帧,这样我就可以全面地查看数据

    # Sets Parameters 
    import os
directory = 'C:\Test\TG'
line_remove = 5
    rename = 'File00'
    extension = 'csv'

os.chdir(directory)
# Rename_files
paths = (os.path.join(root, filename)
        for root, _, filenames in os.walk(directory)
        for filename in filenames)

    for path in paths:
        # the '#' in the example below will be replaced by the '-' in the filenames in the directory
        newname = path.replace(rename, '')
        if newname != path:
            os.rename(path, newname)

    import glob
    # Remove top lines
    myfiles = glob.glob('*.csv')
    for file in myfiles:
        lines = open(file).readlines()
        open(file, 'w').writelines(lines[line_remove:])

# add columns
import glob
import os
import pandas as pd

    myfiles = glob.glob('C:\Test\TG\*.csv')
    for file in myfiles:
        with open(file, 'r') as f:
            data = f.readlines()
        data[0] = 'Count,Line,Date'+'\n'
        with open(file, 'w') as f:
            for element in data:
                f.write(element)

import pandas as pd
import glob

files = glob.glob('C:\BHPB\TG\*.csv')
df = pd.concat([pd.read_csv(fp).assign(Filename=os.path.basename(fp).split('.')[0]) for fp in files], engine ='python')
即使在使用engine=“python”方法之后,在尝试定义数据帧时仍然会出现以下错误

ParserError:标记数据时出错。C错误:字符串内的EOF 从第109043行开始