Сохранение значений в словарь из программы чтения CSV-файлов - ValueError - PullRequest
0 голосов
/ 14 марта 2019

Я пытаюсь прочитать CSV и сохранить его в словаре для дальнейшей обработки, но я получаю valueError.

aBody = {Id: aBody for Id, aBody in reader}
ValueError: not enough values to unpack (expected 2, got 1)

Мой CSV-файл выглядит так:

Id;aBody
100479;"<p>Here is good example:
<a href='http://www.codeproject.com/KB/dotnet/neuralnetwork.aspx'rel='noreferrer'>Brainnet 1 - A Neural Netwok Project - With Illustration And Code - Learn Neural Network Programming Step By Step And Develop a Simple Handwriting Detection System</a> that will demonstrate some practical uses of neural network programming.</p>"
1473317;"<p>Following on from dmckee's answer:</p>

<p>a x b = (a2b3 ? a3b2), (a3b1 ? a1b3), (a1b2 ? a2b1)</p>

<p>In your case a1=1, a2=0 a3=A  b1=0 b2=1 b3=B</p>

<p>so = (-A), (-B), (1)</p>"
1478163;"<p>Yes, devices like the Nintendo DS are plenty powerful enough for this sort of thing.  I haven't worked with the Nintendo DS specifically, but I have written a neural network character recognition app for a Windows Mobile smartphone, which is comparable in processing power.</p>

<p>As you mention, it all depends upon how you write it.  You could just as easily write something that <em>doesn't</em> work on the Nintendo DS.</p>"

Код, который я пробовал, выглядит следующим образом:

with open('edited.csv', 'r') as aBody:
    reader = csv.reader(aBody)
    next(reader)
    aBody = {Id: aBody for Id, aBody in reader}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...