0
I have a list in Python and I want to replace certain elements in it, already try to use the replace mode I found in the documentation, but I did not succeed because it cannot be used in lists.
I have a list as follows.
Mylist = ['Ford"~"Fiat"~"Ka"~"Palio']
This list is composed of a single element, using the function Len(line) it returns me the value 1.
I need to treat this line to get out the following way.
NewList= ['Ford','Fiat','Ka','Palio']
I’m trying in many ways and I’m not getting the expected result.
My code:
encoding='utf-8'
import csv
NewMatriz = []
ficheiro = open('C:\\Users\\asus\\Documents\\models.csv', 'r', newline='', encoding="utf8")
reader = csv.reader(ficheiro)
for item in reader:
NewMatriz.append(item.replace('"','').split('~'))
What is the content of
models.csv
?– Woss