Data won't load from text file - ValueError: not enough values to unpack (expected 3, got 1)
<p>Can't get this text data to load:</p>

<pre class="lang-none prettyprint-override"><code>Al,95191,619851,
Joe,651651,616951,
</code></pre>

<p>The load module:</p>

<pre><code>def loadPlayers():
    Roster = {}
    filename = input("Filename to load: ")
    inFile = open(filename, "rt")
    print("Loading data...")
    while True:
        inLine = inFile.readline()
        if not inLine:
            break
        inLine = inLine[:-1]
        name, phone, jersey = inLine.split(",")
        Roster[name] = Players(name, phone, jersey)
    print("Data Loaded Successfully.")
    inFile.close()
    return Roster
</code></pre>

<p>I get this error:</p>

<pre class="lang-none prettyprint-override"><code>line 103, in loadPlayers name, phone, jersey = inLine.split(",")
  ValueError: not enough values to unpack (expected 3, got 1)
</code></pre>

<p>You can improve the script a little to parse better some cases of extra data not formated as suspected.</p>

<pre><code>def loadPlayers():
    Roster = {}
    filename = input("Filename to load: ")
    inFile = open(filename, "rt")
    print("Loading data...")
    while True:
        inLine = inFile.readline()
        if not inLine:
            break
        inLine = inLine[:-1].split(",")
        if len(inLine) != 3:
            continue
        name, phone, jersey = inLine.split(",")
        Roster[name] = Players(name, phone, jersey)
    print("Data Loaded Successfully.")
    inFile.close()
    return Roster
</code></pre>

python