0

I used sed = np.loadtxt("file.dat") to read the dat file which include different signals. However, I got UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1406: character maps to <undefined>. May I know how can I solve this issue? I am not sure how to read the .dat file which contains the vibration signal.

Susan
  • 431
  • 1
  • 4
  • 16
  • Does this answer your question? [How to fix ''UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 29815: character maps to ''?](https://stackoverflow.com/questions/49562499/how-to-fix-unicodedecodeerror-charmap-codec-cant-decode-byte-0x9d-in-posit) – ewokx Apr 14 '22 at 06:43
  • https://stackoverflow.com/questions/49640513/unicodedecodeerror-charmap-codec-cant-decode-byte-0x9d-in-position-x-charac – Kovy Jacob Apr 14 '22 at 06:43
  • Hello @ewong, I also tried with ```np.loadtxt("file.dat",encoding="utf-8")``` and got the error ```UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaf in position 51: invalid start byte``` ```np.loadtxt("file.dat",encoding="cp437")`` and got the error ```ValueError: could not convert string to float: '\x00k\x00+\x00UniversalDataBinFile'``` – Susan Apr 14 '22 at 06:47
  • I also tried ``` with open("file.dat",encoding="cp437") as file: long_description = file.read()``` This one I don't get any issue. However, long_description is not data , It gives string which I don't need – Susan Apr 14 '22 at 07:00
  • My dat file contains ``` b>-Õ¡=\ˈ?)þèX #†’>à …¿‚X÷>”7E?£¸Â?õÅ@?Ýöc?ŸÛ?ÕH‹?É éX Ë4¾xuŽ?î‹¿Ékb¾÷¢–¿û2>o¾´Â$?¯íQ>û+Ž?\y„?™k¦?`œéX ¾[>“Ã]¿Ñ€¼½êܾ_/"ÀÈ{€¿bÁ|½% 2¿ˆ¾¶<"«8¿s¢ >N2ö= #éX ¨ ¾#ßz?ñƒâ>]׌½4˜¿Ž13¿yù¿¨Á¿ú)„?ÂÓ¿i‹’¿VX¿ ©éXÂ È i<4+?$^Ô½Û‹“¿n†Š>>ŽE¿Z<ù>®{ÀñV¾ T®¿}:ä>Í7À@0éX /µ= áó¾Íoé½¶#’=[M?ÿL?cû³¾#PO¿O”a>Ê¡>|í÷¾±h¿à¶éX ©>”@˜$²¿ªÝþ<û…?Îú¬?2º$>š&?e4¿üOP?äI•¾ÕD=€= éX ̔ù>ƒ0¿´Ñ¾ÀCL?ÏUP?,Yœ¿LŸ¿HºŽ?TTe¿©g0?ëÒ?,”Ï? Ä éX FY¢=—³?¹²ê½ Ê›>xZ?O²F?Yš‡¿Òåº?tü=i¿@œWÅ¿$@?ÀJéX LÙ½tïd¿Ä%<ê.¾>B|Ծ⠄½@åRºMÁ?‡« ¿ðú ?SH``` – Susan Apr 14 '22 at 07:21
  • May I know what is this format? Actually, signal data are stored in dat file format. How can I extract this one to the data? – Susan Apr 14 '22 at 07:24
  • There is no single "dat format"; the `.dat` filename suffix is applied to files containing all sorts of different stuff. You need to find a specification of exactly what sort of data it is that you have. – Ture Pålsson Apr 14 '22 at 08:52
  • It said "UDBF" file type and file extension is dat. – Susan Apr 14 '22 at 09:02

0 Answers0