Python csv without header

前端 未结 3 1419
死守一世寂寞
死守一世寂寞 2021-01-01 13:32

With header information in csv file, city can be grabbed as:

city = row[\'city\']

Now how to assume that csv file does not have headers, th

3条回答
  •  暖寄归人
    2021-01-01 14:04

    You can use pandas.read_csv() function similarly to the way @nosklo describes, as follows:

    df = pandas.read_csv("A2", header=None)
    print df[0]
    

    or

    df = pandas.read_csv("A2", header=None, names=(['city']))
    print df['city']
    

提交回复
热议问题