title: How can I read .dat file containing multiple tables into a pandas data frame?
body: <p>I have a measuring device that records data in .dat files like raw_data.dat in <a href="https://github.com/sgadzhev/importing_dat_files" rel="nofollow noreferrer">this folder</a>, all with the same structure, and I want to be able to extract the last table in the file into a pandas data frame.</p>
  
  <p>The file has a few tables and I am not sure if the tabulation structure here is standard for .dat files but I have tried to paste the text into excel and it recognises the text as separate table, so there is probably a fairly standard way to read the structure correctly into python. I couldn't find one so I've tried a really convoluted way, reading the .dat file into a string and manually chopping off the top of part of the file and saving the rest as .dat file. My hope is to then somehow be able to save the result as a .csv or .xls but I still can't find how to do that either. Furthermore after importing the tabulation is converted to \t's and this doesn't go back to tabulation in the saved files. My code for that is below</p>
  
  <pre class="lang-py prettyprint-override"><code>
  mylines = []                             
  with open ('raw_file.dat', 'rt') as myfile:
      for myline in myfile:
          mylines.append(myline)
  
  string = (mylines[8:])
  
  with open("updated.dat", "w") as output:
      output.write(str(string))
  
  </code></pre>
  
  <p>I must admit I am fairly new to python and I am not certain I use the functions correctly. Still, I hope there is a more straightforward way to go about it than the workaround I am attempting.</p>