0

I am trying to convert a DAT file which has two sheets in it and multiple columns in one sheet. I suspect that it is a binary file as I am not able to open it using a text editor and when I tried to export it into an excel file format using an internal software it showed that the DAT file has two sheets with one sheet containing some header information while the other sheet is in tabular form. I am now trying to convert these DAT files into CSV format using Python because I would like to convert all the files which I am not able to do so using the internal software.

I have tried a few sample codes that I could find here but it doesn't give me the expected results.

df = np.fromfile('test.DAT')

using the code above that somewhat worked, resulting in array forms as below without any header but I expect it to be in a tabular format.

array([6.01347002e-154, 6.01347037e-154, 3.91007023e+097, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000])

I am not sure how to deal with a DAT file that is resulting in 2 sheets when it is exported as an excel file. Any tips or help on this is much appreciated and I hope my question is clear.

3
  • Maybe pandas could be an approach. Check this out and see if it helps :) Commented Feb 13, 2019 at 15:33
  • thanks, I manage to figure out that the file format is in .mdf mode. so now the issue is I need to find a way to convert these .mdf files that are saved as .dat files into .csv format Commented Feb 14, 2019 at 10:13
  • I have solved this problem by using the script below: yop = MDF(filename) df = yop.export('csv', filename = csv_folder) Commented Feb 21, 2019 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.