Python csv without header

前端 未结 3 1435
死守一世寂寞
死守一世寂寞 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:30

    I'm using a pandas dataframe object:

    df=pd.read_sql(sql_query,data_connection)
    df.to_csv(filename, header=False, index=False)
    

    Don't know if that is the most Pythonic approach, but it gets the job done.

提交回复
热议问题