![](/img/trans.png)
[英]How to clean this csv data so that I can read it into a pandas dataframe
[英]How to clean my data, so that I can convert it into a csv file
我有一個如下所示的文本文件。 我的問題是,有沒有一種方法可以清理數據而無需手動執行,以便我可以將其轉換為 csv 之類的數據格式?
Word, Hiragana, English
會う, あう -to meet
青, あお -blue
青い, あおい -blue
赤, あか -red
赤い, あかい -red
明い, あかるい -bright
秋, あき -autumn
開く, あく -to open,to become open
開ける, あける -to open
上げる, あげる -to give
朝, あさ -morning
朝御飯, あさごはん -breakfast
あさって -day after tomorrow
足, あし -foot,leg
明日, あした -tomorrow
あそこ -over there
遊ぶ, あそぶ -to play,to make a visit
暖かい, あたたかい -warm
頭, あたま -head
新しい, あたらしい -new
あちら -there
暑い, あつい -hot
熱い, あつい -hot to the touch
厚い, あつい -kind, deep, thick
あっち -over there
這樣的事情應該適用於您的情況:
for l in textfile:
split1 = l.split(',', 1) # split on first occurance of ',' in line
word = split1[0] # take the first argument of the split as word
split2 = split1[0].split('-', 1) # split the second part with first occurance of '-'
hiragana = split2[0]
english = split2[1]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.