Python help reading csv file failing due to line-endings

后端 未结 3 2010
遇见更好的自我
遇见更好的自我 2021-01-12 02:53

I\'m trying to create this script that will check the computer host name then search a master list for the value to return a corresponding value in the csv file. Then open a

3条回答
  •  感动是毒
    2021-01-12 03:45

    I would populate a dictionary like this:

    >>> import csv
    >>> name_to_UID = {}
    >>> for row in csv.DictReader(open(filename, 'rU'), delimiter='\t'):
        name_to_UID[row['Name']] = row['UID']
    >>> name_to_UID['Carmen-Jackson.local']
    'carmenj'
    

提交回复
热议问题