-3
我有這樣的數據集:的Python - 在CSV行的替換值文件
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
基本上我想「0」遞增地改變所述第二字段爲「1」的程序的每次運行之後,像這個:
['XXXX-XXXX', '1'] # first run
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '1'] # second run
['XXXX-XXXX', '1']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '0']
['XXXX-XXXX', '1'] # eigth run
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
['XXXX-XXXX', '1']
該.csv文件應該直接編輯。我對如何解決這個問題沒有絲毫的想法,我是一個蟒蛇新手..
找到的第一個0,更改爲1,那麼只寫線條 – 2015-02-09 18:30:07
的其餘部分如果你還沒有絲毫的想法如何處理問題,那麼您在這裏詢問時沒有正確使用Stack Overflow。這是爲了當你中途遇到問題而陷入困境時。你剛剛開始。 – 2015-02-09 18:30:11
這可能會幫助你http://stackoverflow.com/questions/11033590/change-specific-value-in-csv-file-via-python – 2015-02-09 18:40:02