Python ParserError:标记数据时出错。C错误:从第行开始的字符串内的EOF
我有大约58个数据源,我正试图找到它们,但收到了标题中的错误。 我在这方面做了很多研究,但从google/stackoverflow等的一些解决方案中仍然没有结果。 我正在做的是删除每个文件的前5行,在一个新列中使用文件名作为引用,然后将它们组合成一个数据帧,这样我就可以全面地查看数据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
# 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行开始