Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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 在windows下提供指向熊猫的路径_Python_Pandas_Path - Fatal编程技术网

Python 在windows下提供指向熊猫的路径

Python 在windows下提供指向熊猫的路径,python,pandas,path,Python,Pandas,Path,嗨,我有下面的代码,它使用os.path.split()和os.sep来创建pandas必须打开但仍然无法打开的文件的路径。更详细地说,我使用递归的os.path.split创建了一个包含文件路径中所有文件夹的列表: def PathDisintegrator(Inp_File): Folders = os.path.split(Inp_File) LastFolder = Folders[1] RootPath = Folders[0] Dirs=[]

嗨,我有下面的代码,它使用os.path.split()和os.sep来创建pandas必须打开但仍然无法打开的文件的路径。更详细地说,我使用递归的os.path.split创建了一个包含文件路径中所有文件夹的列表:

def PathDisintegrator(Inp_File):
    Folders = os.path.split(Inp_File)
    LastFolder = Folders[1]
    RootPath = Folders[0]
    Dirs=[]
    while not(LastFolder==''):
        Dirs.insert(0,LastFolder)
        Folders = os.path.split(RootPath)
        LastFolder = Folders[1]
        RootPath = Folders[0]
    Dirs.insert(0,RootPath[:-1])
    Dirs=Dirs[:-1] 
    return(Dirs)
然后,我将它们链接到一个新文件,该文件是我使用folder+os.sep递归创建的:

def PathAndFile(Folders,File):
    FileOut=''
    for item in Folders:
        FileOut=FileOut+os.sep+item
    FileOut=FileOut[1:]+os.sep+File  
    return(FileOut)
主要内容如下:

import subprocess as sb
import os
from tkFileDialog import askopenfilename 
curfolder=os.getcwd()
import matplotlib.pyplot as plt
import pandas as pd
Inp_Filename=askopenfilename()
Job_Directory = os.path.split(Inp_Filename)[0]
Folders=PathDisintegrator(Inp_Filename)
LDPE_angle=0
FinalDisplacement=6.2328
RateTest=0.01
Width=15.0e-3;
Length=100.0e-3;
ThicknessLDPE=53.0E-06;
ElemNumLength=100.0;
ElemNumWidth=40;
PythonScript=sb.Popen(["abaqus.bat","python","ExtractNumData.py","DOWLEX_PET_LAMINATE_PROTO_REFERENCE_SI_Version_2_Revision_1_MDangle0_Rate001.odb"],stdout=sb.PIPE,stderr=sb.PIPE,cwd=Job_Directory)
Resultfileeeeeee=PythonScript.communicate()[0]
ResultFile2=PathAndFile(Folders,Resultfileeeeeee)
ResultsTemp1=pd.read_csv('D:\\Abaqus_Runs\\DOWLEX_PET_LAMINATE_PROTO_REFERENCE_SI_Version_2_Revision_1_MDangle0_Rate001_MOVING_NODE_out.csv')
ResultsTemp0=pd.read_csv(ResultFile2)
但实际上,命令
pd.read\u csv(ResultFile2)
失败,代码为IOerror文件不存在,相反,命令
resultstep1=pd.read\u csv('D:\\Abaqus\u Runs\\DOWLEX\u PET\u laming\u PROTO\u REFERENCE\u SI\u Version\u 1\u MDangle0\u Rate001\u MOVING\u NODE\u out.csv')
成功。 我的代码中有什么错误

提前感谢您的支持


卢卡

你不能打印出
ResultFile2
并比较它们吗?打印时什么是
ResultFile2
?您至少应该提供此功能,并查看
os.path.join
以将路径连接在一起。结果文件2是*.csv文件。我也尝试过不起作用的join,而且我不能以迭代的方式使用join,因为它对“\”不起作用。相反,我认为问题在于驱动器号“D:”的管理,但如何解决呢?