1

I am relatively new to python and am not even sure if this is at all possible as clipper header files are written entirely in C to my limited knowledge. I am hoping someone might have some idea of how to open a .CH file such as '''ECD1B.CH''' Below is how the file is being opened:

    CH_File = glob.glob(folderView + "**/*.CH", recursive = True)
    CH_File2 = CH_File[0]
    print (CH_File2)
    CH_Opened = open(CH_File2, 'r')
    print (CH_Opened)

The following opened file that python prints is:

<_io.TextIOWrapper name='C:\Users\342232\Documents\MATLAB\10OCT19 Data Folders BHP\20SEPS36.D\ECD1B.CH' mode='r' encoding='cp1252'>

Clearly, python was unable to print the actual content embedded in the file. I am wondering if this is even possible to open in python. I do have a friend that wrote code in Matlab that can open this file type. Open to any suggestions and thank you in advance.

daShier
  • 2,056
  • 2
  • 8
  • 14
  • `CH_Opened` is a file object, you need to actually read from it, e.g.: `CH_Opened.readlines()` – UnholySheep Oct 16 '19 at 17:42
  • @UnholySheep Right, thank you. Once I fix that issue, and attempt to print again, I receive the following error: " UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 1483: character maps to " – Danny Huber Oct 16 '19 at 17:49
  • I believe this is an issue of Python not being able to properly decode the file type. I might just need to find the proper encoding format in order to open the file. – Danny Huber Oct 16 '19 at 18:15

0 Answers0