0
的:編輯我已經生成一個CSV文件,它看起來像這樣一個CSV文件
50,57,13,10,50,48,13,10,49,55,13,10,49,54,13,10,49,52,13,10,49,52,13,10,49,50,13,10,49,49,13,10
49,49,13,10,57,13,10,57,13,10,57,13,10,56,13,10,56,13,10,55,13,10,54,13,10,54,13,10,54,13,10,54
13,10,54,13,10,54,13,10,54,13,10,53,13,10,54,13,10,54,13,10,54,13,10,54,13,10,54,13,10,53,13,10
53,13,10,52,13,10,52,13,10,52,13,10,53,13,10,53,13,10,53,13,10,52,13,10,51,13,10,52,13,10,52,13
10,52,13,10,53,13,10,52,13,10,51,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51
13,10,51,13,10,52,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,52,13,10,52,13,10,53,13,10
53,13,10,51,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,51,13,10,52,13
10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51
13,10,52,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10
52,13,10,51,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10,51,13,10,50,13,10,51,13,10,51,13
10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,52,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51
13,10,51,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,51,13,10,52,13,10,53,13,10,52,13,10
52,13,10,51,13,10,52,13,10,51,13,10,52,13,10,52,13,10,52,13,10,51,13,10,51,13,10,51,13,10,52,13
我想將它重新構造這樣的,它應該只有一個行,根本沒有列。我試過numpy.genfromtxt
new=np.genfromtxt('repaired.csv', dtype='float', delimiter=',', skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars='"', replace_space='_', autostrip=False, case_sensitive=True, defaultfmt='f%i', unpack=None, usemask=False, loose=True, invalid_raise=True, max_rows=None)
但它沒有工作。我在歌廳錯誤爲:
ValueError: Some errors were detected !
Line #1591 (got 28 columns instead of 32)
Line #1593 (got 4 columns instead of 32)
好像你的一些行可能是幾列簡短的 - 你可以導航到文件中指定的行,看看他們是否格式正確? –
你想作爲'list'嗎? –
錯誤信息不能更清晰...確保你所有的行有相同的長度, –