I'm trying to edit a csv file and replacing some commas in the data. I'm calling my function using:
with open(my_data,'r') as file:
for i in range(3):
print(my_func(file.readline()))
and this is my code
def my_func(data):
my_string=""
my_string=my_string+(data[0:len(data)]) #add first line of csv file
stripped=data.strip()
stripped=stripped.replace(",","") #remove comma from every line
my_string=my_string+(stripped)
print(stripped)
Output returns original data, my edit, None: Not sure where the None values come from.
This,is,the,alphabet #first line of original data
Thisisthealphabet #first line of original data, with replacement of comma applied
None
A,B,C #second line of original data
ABC #second line of original data, with replacement of comma applied
None
D,E,F #third line
DEF
None
Expected:
This,is,the,alphabet #WITH commas, as in original data
ABC
DEF