I have the following .csv
file I'm trying to read as a whole:
---------------------------------------------------------------
#INFO | | | | | |
---------------------------------------------------------------
#Study name | g1 | | | | |
---------------------------------------------------------------
#Respondent Name | name | | | | |
---------------------------------------------------------------
#Respondent Age | 20 | | | | |
---------------------------------------------------------------
#DATA | | | | | |
---------------------------------------------------------------
Row | Timestamp | Source | Event | Sample | Anger|
---------------------------------------------------------------
1 | 133 | Face | 1 | 3 | 0.44 |
---------------------------------------------------------------
2 | 240 | Face | 1 | 4 | 0.20 |
---------------------------------------------------------------
3 | 12 | Face | 1 | 5 | 0.13 |
---------------------------------------------------------------
4 | 133 | Face | 1 | 6 | 0.75 |
---------------------------------------------------------------
5 | 87 | Face | 1 | 7 | 0.25 |
---------------------------------------------------------------
This is the code I am using to open, read the file, and print to the terminal:
import csv
def read_csv():
with open("in/2.csv", encoding="utf-8-sig") as f:
reader = csv.DictReader(f)
print(list(reader))
read_csv()
The output I am getting includes only the first two columns of my .csv
:
[{'#INFO': '#Study name', '': ''}, {'#INFO': '#Respondent Name', '': ''}, {'#INFO': '#Respondent Age', '': ''}, {'#INFO': '#DATA', '': ''}, {'#INFO': 'Row', '': 'Anger'}, {'#INFO': '1', '': '4.40E-01'}, {'#INFO': '2', '': '2.00E-01'}, {'#INFO': '3', '': '1.30E-01'}, {'#INFO': '4', '': '7.50E-01'}, {'#INFO': '5', '': '2.50E-01'}]
Why are the other columns missing from my output? I want the other columns starting from Row
to be included as well. Any direction would be appreciated. Thanks!