这里的代码是,我先读取文件配置,然后再将目录传递到称为ednotes_extractor.get_ednotes()的方法中
from preprocessing import ednotes_extractor
csf_config_txt = open("..\CFS_Config.txt", "r")
file_list = []
root_dir = ""
edn_txt = ""
pcr_txt = ""
for line in csf_config_txt:
file_list.append(line)
if "Folder Path = " in file_list[0]:
root_dir = str(file_list[0])
root_dir = root_dir.replace("Folder Path = ", "")
root_dir = root_dir.replace("\n", "")
if "ED Notes = " in file_list[1]:
root_dir = str(file_list[1])
root_dir = root_dir.replace("ED Notes = ", "")
root_dir = root_dir.replace("\n", "")
if "Patient Care Record = " in file_list[2]:
root_dir = str(file_list[2])
root_dir = root_dir.replace("Patient Care Record = ", "")
root_dir = root_dir.replace("\n", "")
print(file_list[2])
def convert_txt(choices):
if(choices == 1):
#I would like to pass a directory in this method called theednotes_extractor
ednotes_extractor.get_ednotes(str2=file_list[1])
elif(choices==2):
print("Hi")
答案 0 :(得分:0)
也许这会有所帮助
arr1 = [1,2,3]
arr2 = [4,5,6]
只需添加两个不带[]的数组
arr3 = arr1 + arr2
以您的情况
x = []
for i in range(0, len(arr_cat)):
x += arr_cat[i]
print(len(x))
以上内容就足够了。
答案 1 :(得分:0)
列表理解会做到这一点。它将解压缩列表列表并将其放入新列表中。
flat_list = [item for sublist in arr_cat for item in sublist]
arr_cat = flat_list
答案 2 :(得分:0)
尝试一下:
from itertools import chain
new_list = list(chain(*arr_cat))