I have an Excel
file that looks like the following:
First_Name Initials Last_Name Places Email Tel Fax Joint Corresponding Experimental design Data generation Data processing Data analysis Statistical analysis Manuscript preparation
Anna A Karenina BioInform_Harvard anna.Karenina@ucsf.edu 8885006000 8885006001 1 Y Y Y Y Y Y
Konstantin D Levin Neuro_Harvard Konstantin.levin@childrens.harvard.edu 8887006000 8887006001 1 Y Y Y
Alexei K Vronsky IGM_Columbia alexei.vronsky@cumc.columbia.edu 8889006000 8889006001 2 Y
Stepan A Oblonsky NIMH steoblon@mail.nih.gov 8891006000 8891006001 2 Y Y
In my Python
code, to open the file i have written code as follows:
with open(filename, 'r') as f:
for i in f:
i = i.rstrip().split("\t")
print(i)
The resulting list looks as follows. How do I get rid of the '\r'
? I've tried various methods like replacing "\r" with "", but that messes up the elements of the list that look like 'Y\rKonstantin'
.
['First_Name', 'Initials', 'Last_Name', 'Places', 'Email', 'Tel', 'Fax', 'Joint', 'Corresponding', 'Experimental design', 'Data generation', 'Data processing', 'Data analysis', 'Statistical analysis', 'Manuscript preparation\rAnna', 'A', 'Karenina', 'BioInform_Harvard', 'anna.Karenina@ucsf.edu', '8885006000', '8885006001', '1', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y\rKonstantin', 'D', 'Levin', 'Neuro_Harvard', 'Konstantin.levin@childrens.harvard.edu', '8887006000', '8887006001', '1', '', '', '', 'Y', 'Y', 'Y', '\rAlexei', 'K', 'Vronsky', 'IGM_Columbia', 'alexei.vronsky@cumc.columbia.edu', '8889006000', '8889006001', '2', '', '', 'Y', '', '', '', '\rStepan']
I'm able to get rid of newline characters fine, but it's the '\r'
I can't get rid of.