Python write a new csv file by filtering selected rows from an existing csv file

后端 未结 3 1203
刺人心
刺人心 2021-01-29 02:40

just a question, I was trying to write selected rows from a .csv file to a new .csv file, but there is an error.

The test.csv file that I was trying to read is like this

3条回答
  •  半阙折子戏
    2021-01-29 03:15

    Use string.find or regular expressions to find a substring in a string.

    So instead of

    if (rad_line.has_key('2014')):
    

    you can do:

    if (rad_line.find('2014') <> -1):
    

提交回复
热议问题