看板 Python 關於我們 聯絡資訊
試了半天還是失敗Orz 想要請問大家下面的資料中: 1.如何在csv檔中只擷取檔案中*CHI此句話? 2.如何將換行的文字併到同一行?例如:4與5行是屬於同一句文字,如何合併? 感謝大家的幫忙 m(_ _)m 1 *CHI: I saw an elephant go swimming . 2 %mor: pro:sub|I v|see&PAST det:art|a n|elephant v|go part|swim-PRESP . 3 %gra: 1|2|SUBJ 2|0|ROOT 3|4|DET 4|5|SUBJ 5|2|COMP 6|5|OBJ 7|2|PUNCT 4 *CHI: <I saw eleph> [//] I saw the <g> [/] giraffe and the elephant <s> 5 [//] drop ball in the pool . 6 %mor: pro:sub|I v|see&PAST det:art|the n|giraffe coord|and det:art|the 7 n|elephant n|drop n|ball prep|in det:art|the n|pool . 8 %gra: 1|2|SUBJ 2|0|ROOT 3|4|DET 4|2|OBJ 5|4|CONJ 6|9|DET 7|9|MOD 8|9|MOD 9 9|5|COORD 10|9|NJCT 11|12|DET 12|10|POBJ 13|2|PUNCT 10 *CHI: I saw giraffe swimming in the pool to get that ball . -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.147.13.92 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1539186346.A.1BD.html
HenryLiKing: 第一題用RE應該可以 感覺~ 10/10 23:57
cancelpc: 這不是標準的 CSV 格式吧,自己用 re 剖析處理比較快 10/11 02:02
mirror0227: 這哪裡是CSV 一個逗點都沒有XD 換行合併抓\n刪掉就好 10/11 16:33