vendredi 23 juillet 2021

Python: Writing column in CSV with if-statement

Using Python, I'd to write a specific text in a CSV file when it is not equal to the value "null". That sounds like I need a if/then statement, but I'm uncertain how to structure it.

The original CSV format is:

CSV1

I'm seeking to add another column "text_number" that will insert the string "text_x" if the value is not null. I'd like to iterate this and increase the string's value by 1 for each text. The final product would look like:

CSV2

Any thoughts on how to proceed?

Aucun commentaire:

Enregistrer un commentaire