title: How can I remove '\r' in a loop to read files in python
body: <p>Does anyone know how to get rid of '\r'?</p>
  
  <p>I have to run 89 files in the supercomputer, I have done so far the two next scripts </p>
  
  <p>The first one is .sh to run it on shell</p>
  
  <pre><code>$ID=$(sed "${PBS_ARRAYID}q;d" ID_index.txt)
  $echo "Processing $ID"
  $python $PBS_O_WORKDIR/script.py $ID
  </code></pre>
  
  <p>where the ID_index text implies the index from 1 to 89 datafiles</p>
  
  <p>Then I have the next script in python</p>
  
  <pre><code>#!/usr/bin/python
  
  import pandas as pd
  import numpy as np
  import sys
  
  ID_1 = sys.argv[1]
  vcf_info = sample_id + '.snp.INFO'
  
  
  ID_1 = sys.argv[1]
  ID_1_info = ID_1 + 'sample_cases.lgen'
  ID_2 = sys.argv[2]
  ID_2_info = ID_2 + 'sample_controls.lgen'
  
  # Reading files
  
  df_1 = pd.read_table(ID_1_info, delim_whitespace=True , header=None)
  df_2 = pd.read_table(ID_2_info, delim_whitespace=True , header=None)
  
  .
  .
  .
  </code></pre>
  
  <p>Because the output link to read the datafiles returns a space, this is the error:  </p>
  
  <blockquote>
    <p>df_1 = pd.read_table(ID_1_info, delim_whitespace=True , header=None)
      File "pandas/io/parsers.py", line 685, in parser_f return _read(filepath_or_buffer, kwds)
      File "pandas/io/parsers.py", line 457, in _read parser = TextFileReader(fp_or_buf, **kwds)
      File "pandas/io/parsers.py", line 895,
    .
    .
    .
    pandas._libs.parsers.TextReader._setup_parser_source
    FileNotFoundError: [Errno 2] File b'1\r_sample_cases.lgen' does not exist: b'1\r_sample_cases.lgen'</p>
  </blockquote>
  
  <p>The original name of the data to read is 1_sample_cases.lgen </p>
  
  <p>How can I remove '\r' or at least replace them that the result looks like the name of the data file? I did read a lot of answers about this, but none helped.</p>
  
  <p>Hopefully someone can help me. Thank you,</p>
  
  <p>Ale.</p>