Hi, there are two ways to do this, the most elegant and using a library for python called "pandas" this is the link for their website, it has how to install using python’s "Pip" and has all documentation on their website.
But I’ll write you a less elegant way, but it solves your problem.
Input : data.csv
Serial; Imei; Número; Icc; Stock
869606020314526; 869606020314526; 934097609; 20000736862016; Stock
Script : numeroUpdate.py
file_in = open('data.csv','r')
file_out = open('numero_atualizado.csv','w+')
next(file_in) # Pois queremos pular a primeira linha.
file_out.write('Serial; Imei; Número; Icc; Stock\n') # Cabeçario do arquivo, e o "\n" é para pular de linha.
string = '' # Criado para podermos chamar o metodo join.
for line in file_in:
line = line.split('; ') # No split, cortamos string.
numero = "+244" + line[2]
line[2] = numero
file_out.write(string.join(line))
file_out.close()
I think it might help, anything, just comment.
You can share what you’ve tried, the code and the specific error you’ve stumbled into?
– Pedro von Hertwig Batista
If one of the answers below solved your problem and there was no doubt left, choose the one you liked the most and mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you still have any questions or would like further clarification, feel free to comment.
– Lucas