From 84c22204cc22b8310f1265a4c15f3d3f1458fda3 Mon Sep 17 00:00:00 2001 From: iansun2 Date: Mon, 19 Jun 2023 19:53:55 +0800 Subject: [PATCH] fix question 3-11 --- convert.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ output.csv | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 convert.py diff --git a/convert.py b/convert.py new file mode 100644 index 0000000..bff7044 --- /dev/null +++ b/convert.py @@ -0,0 +1,68 @@ +import csv + +csv_file = open("output.csv", mode="w", encoding="UTF-8", newline='') +writer = csv.writer(csv_file) +src_file = open("drone.txt", mode="r", encoding="UTF-8") +src_string = src_file.read() +chap1_pos = src_string.find("第一章") +chap2_pos = src_string.find("第二章", chap1_pos) +chap3_pos = src_string.find("第三章", chap2_pos) +chap4_pos = src_string.find("第四章", chap3_pos) +chap1_ans_pos = src_string.find("第一章", chap4_pos) +chap2_ans_pos = src_string.find("第二章", chap1_ans_pos) +chap3_ans_pos = src_string.find("第三章", chap2_ans_pos) +chap4_ans_pos = src_string.find("第四章", chap3_ans_pos) + + + + +data_list = [] + +def getBlock(current_pos, end_pos, current_ans_pos, end_ans_pos, label): + question_number = 1 + while(1): + search_key = str(question_number) + ". " + question_pos = src_string.find(search_key, current_pos, end_pos) + if(question_pos == -1): + break + #print(src_string[question_pos:].split("\n")[0]) + options1_pos = src_string.find("(A)", question_pos, end_pos) + options2_pos = src_string.find("(B)", options1_pos, end_pos) + options3_pos = src_string.find("(C)", options2_pos, end_pos) + options4_pos = src_string.find("(D)", options3_pos, end_pos) + + question_str = src_string[question_pos:].split("\n")[0] + options1_str = src_string[options1_pos+4 : options2_pos] + options2_str = src_string[options2_pos+4 : options3_pos] + options3_str = src_string[options3_pos+4 : options4_pos] + options4_str = src_string[options4_pos+4:].split("\n")[0] + + #print(question_str) + question = [] + question.append(question_number) + question.append(question_str.split(search_key)[1]) + #question.append(options1_str.split("(A)")[1]) + #question.append(options2_str.split("(B)")[1]) + #question.append(options3_str.split("(C)")[1]) + #question.append(options4_str.split("(D)")[1]) + + question.append(options1_str.strip()) + question.append(options2_str.strip()) + question.append(options3_str.strip()) + question.append(options4_str.strip()) + + ans_pos = src_string.find(search_key, current_ans_pos, end_ans_pos) + ans_str = src_string[ans_pos:].split(search_key)[1][0] + + question.append(ans_str) + question.append(label+str(question_number)) + data_list.append(question) + #print(question) + question_number += 1 + + +getBlock(chap1_pos, chap2_pos, chap1_ans_pos, chap2_ans_pos, "第一章") +getBlock(chap2_pos, chap3_pos, chap2_ans_pos, chap3_ans_pos, "第二章") +getBlock(chap3_pos, chap4_pos, chap3_ans_pos, chap4_ans_pos, "第三章") +getBlock(chap4_pos, chap1_ans_pos, chap4_ans_pos, -1, "第四章") +writer.writerows(data_list) \ No newline at end of file diff --git a/output.csv b/output.csv index d6fca24..f587d94 100644 --- a/output.csv +++ b/output.csv @@ -271,7 +271,7 @@ 8,於固定空氣體積下,升溫時該體積空氣密度減少,降溫時該體積空氣密度為下列何種變化?,增加。,減少。,不變。,有時增加有時減少。,A,第三章8 9,對流層裡,溫度及壓力均隨高度增加而有下列何種變化?,降低。,增加。,不變。,有時增加有時降低。,A,第三章9 10,下列有關大氣壓力量測之敘述,何者錯誤?,國際標準大氣(International Standard Atmosphere,ISA)為各國公認之參考校正基準。,海平面大氣壓力為 29.92 英吋汞柱(inHg)。,一標準大氣壓力等於 1017.2 毫巴值。,"每上升 1,000 英呎,氣壓值減少約 1 英吋汞柱。",C,第三章10 -11,標準一大氣壓的 29.92 吋汞柱換算成毫巴值為下列哪個數值?,壓力錶廠牌差異。,地面溫度不平均。,壓力錶讀法差異。,壓力錶校正值差異。,C,第三章11 +11,標準一大氣壓的 29.92 吋汞柱換算成毫巴值為下列哪個數值?,10.132。,101.32。,1013.2。,10132。,C,第三章11 12,大氣壓力之實際值與標準值存在差距,係由於哪項因素所影響?,壓力錶廠牌差異。,地面溫度不平均。,壓力錶讀法差異。,壓力錶校正值差異。,B,第三章12 13,若遙控無人機操作人未能注意大氣壓力實際值與標準值間之差距並適時修正,可能無法,實際高度。,實際航向。,實際滾轉角。,實際引擎轉速。,A,第三章13 14,氣象資料顯示某區域之氣壓值有向上提升之趨勢,代表該區域天氣狀況有何種變化?,天氣轉壞。,天氣可能轉好也可能轉壞。,天氣好轉。,以上皆非。,C,第三章14