我想下面的Unicode字符串轉換到一個列表中列出清單結果[我扔在兩個空間,以使其適合...]:轉換CSV到列表
"58478000","","NEW","2016-12-28T14:34:18","C","","","N","N","ON","2017-03-15","2022-03-15","30/360","EUR","IR","","InterestRate:IRSwap:FixedFloat","Trade","EUR-EURIBOR-Reuters","FIXED","Percent","-0.003","","","EUR","EUR","25,000,000","25,000,000","3M","1Y","3M","","","","","","","","","","","","",""
我使用下面的代碼將字符串轉換上面,abc
,到一個列表:
csv.reader(abc, delimiter=',')
details = list(csvreader)
這導致了這個雖然,我似乎無法刪除['','']
容易...
[['58478000'], ['', ''], [''], ['', ''], ['NEW'], ['', ''],['2016-12-28T14:34:18'], ['', ''], ['C'], ['', ''], [''], ['', ''],[''], ['', ''], ['N'], ['', ''], ['N'], ['', ''], ['ON'], ['', ''],['2017-03-15'], ['', ''], ['2022-03-15'], ['', ''], [' 30/360'], ['',''], ['EUR'], ['', ''], ['IR'], ['', ''], [''], ['', ''],['InterestRate:IRSwap:FixedFloat'], ['', ''], ['Trade'], ['', ''],['EUR-EURIBOR-Reuters'], ['', ''], ['FIXED'], ['', ''], ['Percent'],['', ''], ['-0.003'], ['', ''], [''], ['', ''], [''], ['', ''],['EUR'], ['', ''], ['EUR'], ['', ''], ['25,000,000'], ['', ''],['25,000,000'], ['', ''], ['3M'], ['', ''], ['1Y'], ['', ''], ['3M'],['', ''], [''], ['', ''], [''], ['', ''], [''], ['', ''], [''], ['',''], [''], ['', ''], [''], ['', ''], [''], ['', ''], [''], ['', ''],[''], ['', ''], [''], ['', ''], [''], ['', ''], [''], ['', ''], ['']]
我的目標是把這個成某種列表,或任何其他集合的,這使得它更容易提取出的信息的那...
嗨,我正在嘗試此回覆。非常棒 - 謝謝! – keynesiancross
關於你的編輯 - 我不知道我關注。如果x [0]]不起作用,原始細節是否= csvreader中x的[x [0])?它似乎對我來說 – keynesiancross
它的工作不用擔心。我只是在尋找更優雅的東西。 –