-1
나는 v = 0에서 x 인 Star_ {v} 인 x 디렉토리를 가지고있다. 각 디렉토리에 2 개의 csv 파일이 있습니다. 하나는 "epoch"라는 단어가 있고 하나는없는 것입니다. csv 파일 중 하나에 "epoch"라는 단어가있는 경우 하나의 코드 집합을 통해 보내고 다른 코드 집합을 통해 보내야합니다. 나는 사전 아마 갈 방법이 있지만,이 부분의 코드 생각을 잘못 혼란의 비트가파이썬에서 여러 디렉토리와 별도로 여러 파일을 읽는 방법
directory_dict={}
for var in range(0, len(subdirectory)):
#var refers to the number by which the subdirectories are labelled by Star_0, Star_1 etc.
directory_dict['Star_{v}'.format(v=var)]=directory\\Star_{var}
#directory_dict['Star_0'], directory_dict['Star_1'] etc.
read_csv(f) for f in os.listdir('directory_dict[Star_{var}') if f.endswith(".csv")
#reads in all the files in the directories(star{v}) ending in csv.
if 'epoch' in open(read_csv[0]).read():
#if the word epoch is in the csv file then it is
directory_dict[Star_{var}][read] = csv.reader(read_csv[0])
directory_dict[Star_{var}][read1] = csv.reader(read_csv[1])
else:
directory_dict[Star_{var}][read] = csv.reader(read_csv[1])
directory_dict[Star_{var}][read1] = csv.reader(read_csv[0])
유효하지 않은 Python 코드를 게시 한 사실 외에도이 질문에는 의문의 여지가 없습니다. – davidism