Headers with Python List
Question: Python newbie. I have csv data the looks like the following:

    
    
    Record  Name    Cur     e12mo   e24mo   e48mo   state
    3928    Joes    2000    200     400     0       CA,GA
    1       Toms    19       1      2       0       AR,KS
    1747    Mine    60       5      10      0       AR,CT
    5023    Yours   5        12     24      0       FL
    7041    Theirs  10       2      4       0       FL
    

Am entering code from tutorial as follows:

    
    
    import numpy as np
    import csv as csv
    
    readdata = csv.reader(open('c:\MyData\BYLCsv.csv'))
    for row in readdata:
        print(row)
    data = []  
    for row in readdata:
        data.append(row)
    for row in data:
        print(row)
    Header = data[0]
    data.pop(0) 
    

Code bombs on the "Header = data[0]" statement. Everything runs up to there.


Answer: In your first loop, you read the whole file, the file pointer is not reset
afterwards:

    
    
    import numpy as np
    import csv as csv
    with open('c:\MyData\BYLCsv.csv') as data:
        readdata = csv.reader(data)
        header = next(readdata)
        data = list(readdata)
    print(header)
    for row in data:
        print(row)
    

