import csv
from csv import reader
with open("C:\Python37-32\Date_create_count.csv","r") as new:
data = reader(new)
for i in data:
print(i)
provides the output as follows
C:\Users\ybs\PycharmProjects\Pyprgs\venv\Scripts\python.exe C:/Python_prgs/count_by_date_csv.py
['target_release\tid\tstate\trel_state\towner\ts\tp\ttype\tsubtype\t|title\tdate_create\tkeywords']
['et.3\t1053801\tWONT_FIX\tWONT_FIX\tuttams\t4\tB\tSW_SC\tscc\t|[SCC][Longevity]Backup Workflow failing with Token Expired Error\t20161206\tSC42_Triaged_Out', 'source=TestPlanned', 'target=5.0']
['et.3\t1088667\tWONT_FIX\tWONT_FIX\tsgundi\t4\tB\tSW_SC\tcommon_gui\t|External beta 3.0: Resource view selection has to be persisted\t20170530\tSC42_Triaged_Out', 'source=RFE', 'chunk=NA']
When I try to print only tid and tdate_create it gives error
for i in data:
print(i['tid'])
\Users\ybs\PycharmProjects\Pyprgs\venv\Scripts\python.exe C:/Python_prgs/count_by_date_csv.py
Traceback (most recent call last):
File "C:/Python_prgs/count_by_date_csv.py", line 6, in <module>
print(i['tid'])
TypeError: list indices must be integers or slices, not str
Process finished with exit code 1
How I split the string and get tid and tdate_create fields from the csv file
['target_release\tid\tstate\trel_state\towner\ts\tp\ttype\tsubtype\t|title\tdate_create\tkeywords']