Reading row data from CSV file
Question: I'm currently trying to create a program that reads a CSV file, more
specifically row data (data in lines across)

**Sampledata.csv:**

    
    
    ['Time', 'Date', 'Color  ', 'Name']
    ['1pm', '01-01-99', 'blue', 'jack']
    ['2pm', '02-02-99', 'green', 'kevin']
    ['3pm', '03-03-99', 'yellow', 'phil']
    ['4pm', '04-04-99', 'white', 'alice']
    ['5pm', '05-05-99', 'black', 'bob']
    

Here is my code:

    
    
    import csv  
    with open('Sampledata.csv', 'r') as csvfile :
          regnumber = input("What is your regnumber?")
          reader = csv.reader(csvfile, delimiter=',')
    for row in reader:
         print(row) # here lies the problem(python is reading columnal data (data going down) instead of row(lines across) data#
    

The problem is in reading the columns (data going down). Python reads the
columns instead.

Output:

    
    
    Date
    01-01-99
    02-02-99
    03-03-99
    04-04-99
    05-05-99
    


Answer: Is this the one you're looking for?

    
    
    import csv  #ignore my stupidity with the indentation and spaces#
    with open('Sampledata.csv', 'r') as csvfile :
        regnumber = raw_input("Enter the time:")
        reader = csv.reader(csvfile)
        for row in reader:
            if(row[0]==regnumber):
                print ', '.join(row)
            else:
                continue
    

The above code print values from csv file row by row.

