New to Python, need some advice and guidance on how to start

Problem statement - please dont flame, am a complete newbie, would appreciate some help in learning and starting off

I need to scan a CSV file, and I am looking for instances where there is either a 2 digit country code in brackets eg (IN), or “-ADMIN”, or “-M”, or “-T” after a users name, which I need to remove.

My pseudo logic would look something like the below :-

Open CSV file

Loop through file
Field to be changed = Field(10)
i = number
loop for i to len(field(10))
if i = “-” or i = “(”
delete to end of len(field(10))
write new version of field(10)
endif

movenext record in CSV

Close CSV file

Hi Carl, for which part do you think you need help? You pseudo code looks OK-ish, depending on what exactly you want to do. It might help to provide:

  • an example of the CSV file you have
  • the final CSV you want to have

Do you need help writing the Python code? If your goal is to learn, it would be better to start yourself, and post here if you have errors blocking your progress.

1 Like

You should start by reading about the csv module, which gives you a list of strings.