Assuming I have the below dataset
10,"XG16008168",9/12/2017 0:00:00,9/13/2017 0:00:00,2/23/2018 0:00:00,"Whatever","07210","25978","Main","Yes",3/9/2018 0:00:00,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,,0,0,0,0,0,0,0,0,0,1,,0,,0,,0,0,0,0,0,1,0,0,0,0,0,0,,0,
11,"X000000000",11/30/2017 0:00:00,9/25/2017 0:00:00,2/27/2018 0:00:00,"Whatever 004","07210","25978","Main","Yes",3/9/2018 0:00:00,,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,,0,0,0,0,0,0,0,0,0,1,"Missing valve number.",0,,0,,0,0,0,0,0,0,1,0,0,0,0,0,,0,
I read this CSV file using the following:
with open("AccessTable.txt", "r") as RTCData:
with open("RTCOutput.csv", "w") as RTCOutput:
ALLRows = csv.reader(RTCData, delimiter=',')
for row in ALLRows:
rows.append(row)
print(row[1][1])
I am trying to print an element of the CSV file.
So by printing row[1][1] I was expecting "X000000000" but instead I get "1" which is the second character in "11".
Can you please tell me how to spit out how to extract elements?
with open("AccessTable.txt", "r") as RTCData:print(rows[1][1])(note rows, not row). Another problem is that your code is seemingly misaligned, theprint(rows[1][1])shouldn't be outside of thewithblocks, when all file i/o has been completed?