Python csv tags
I have a csv file with different headers.
name,city
john doe,chicago
Have headers as
reader = csv.DictReader开发者_StackOverflow社区(open(PATH_FILE),skipinitialspace=True)
headers = reader.fieldnames
How will you run a regex that whenever a tag [name] was to be proceesed it will show "john doe"
You could use re.sub()
with a function passed as repl
, or you could just use string interpolation with a mapping:
print 'My name is %(name)s' % rowdict
精彩评论