Remove a single row from a csv without copying files

后端 未结 7 2175
青春惊慌失措
青春惊慌失措 2020-12-06 00:07

There are multiple SO questions addressing some form of this topic, but they all seem terribly inefficient for removing only a single row from a csv file (usually they invol

相关标签:
7条回答
  • 2020-12-06 00:51

    You can do it using Pandas. If your data is saved under data.csv, the following should help:

    import pandas as pd
    
    df = pd.read_csv('data.csv')
    df = df[df.fname != 'Sarah' ]
    df.to_csv('data.csv', index=False)
    
    0 讨论(0)
提交回复
热议问题