File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11
2- # CSVs
2+ # CSVs, a basic guide; see
3+ # https://www.opentechguides.com/how-to/article/python/181/csv-read-write.html
4+
5+ import csv
6+ from pathlib import Path
7+
8+ filepath = Path ('./data/VernonAuthority.csv' )
9+ print (f"\n Working with { filepath .absolute ()} \n " )
10+
11+ with open (filepath , mode = 'r' , newline = '' ) as auth_list :
12+
13+ dict_reader = csv .DictReader (auth_list )
14+
15+ dict_reader .fieldnames = [field .strip ().lower ().replace (' ' , '_' )
16+ for field in dict_reader .fieldnames ]
17+ print (f"Headers: { '; ' .join (dict_reader .fieldnames )} \n " )
18+
19+ for row in dict_reader :
20+ print (row ["system_id" ] + "|" + row ['name' ] + "|" + row ["long_name" ])
21+
22+ # For a more fulsome explanation, see https://thispointer.com/?p=4309
You can’t perform that action at this time.
0 commit comments