this is my main string
"action","employee_id","name"
"absent","pritesh",2010/09/15 00:00:00
so after name coolumn its goes to new line but here i append to list a new line character is added and make it like this way
data_list***** ['"action","employee_id","name"\n"absent","pritesh",2010/09/15 00:00:00\n']
here its append the new line character with absent but actually its a new line strarting but its appended i want to make it like
data_list***** ['"action","employee_id","name","absent","pritesh",2010/09/15 00:00:00']
Davide's answer can be written even simpler as:
data_list = [word.strip() for word in data_list]
But I'm not sure it's what you want. Please write some sample in python.
replaces = inString.replace("\n", "");
First, you can use strip()
to get rid of '\n'
:
>>> data = line.strip().split(',')
Secondly, you may want to use the csv module to do that:
>>> import csv
>>> f = open("test")
>>> r = csv.reader(f)
>>> print(r.next())
['action', 'employee_id', 'name']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With