Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:04:27+00:00 2026-05-26T20:04:27+00:00

I am reading in a fortran unformatted file. If I use Python to read

  • 0

I am reading in a fortran unformatted file. If I use Python to read them in,

import struct
f = open(filename,'r')
values = struct.unpack('%20s',f.read(20))

I get characters like

\xf8, \xbf, \xad, \xe8, \xd8, \xec, \xd5, \x10, \xfd, \xbf

and so on. Each of these are of length one and string replacement functions do not work on them.

What character set am I dealing with?

Edit

pasting partial output of f.read():

\xdf\xde#\xc0|\x18B\x9f\xec\xd6!\xc0]\x0b\x08b\xb1k#\xc0R#g}\xae\x14\xe8?\xde\x1c\x84b\x07S\xe8?.\x0b\x15\x07\xae\x99\xc5\xbf\xac\x9c\xa4\xf0\x8aV\xe4?K\t\x8a(3/\x07@\x97]rW\x8e?\x0b@\xe8\xfe\x9f0\x92P\x04@\xc6&\x98-VV\x07@\xa2\x8e\x86\xa8\xf2-\x18@N\xca\xa6\xc9\xe3W\x1b@\x1f\x96\x0f\xb2\nH\x18@\xc31Jv\xf8\x98\x18@\xacOBu\xcf\xd6'@A\xf0\x9fJ\x84{(@\x1d`.N\x9b\x15'@4\xa5\xb2\x91)\xd3'@\x851\x9d\x83\x98\x00\x02\xc0\xa2Iy\x1b\xca\xf2\x04\xc0eu\rt\xb2\xd5\x04\xc0V\x92\xaf\x9f\xf6\xbd\x02\xc0:\r\xfc\xc6\xf8\xfb\xae\xbf!\x95QZ\xcdx\xe7\xbf\x8e\xd9O\xdf\xd1\xc0\xe4?\xbe\xba\xae\xa5\xb3\x9e\xac\xbfJ0h('=\xf0?\x83\xd67\xcf\n4\xe0?$\xf9\x0c\x00\x05\xe5\xfc?\x97+c\x9d\xd1\xf0?V\xfc\xc8\xe4\x12\x98\xf3?m\x8aa\xc4\xe5}\xf8?s\x9b\xb4{\xf22\x00@\xc3t'\xd0-\xdc\xf5?\xf9\x8eb&Y\x7f\x0c\xc0\x8c\x91\xa7\xe2\xf0|\x0c\xc0d\xd3b\x1a_\x05\x06\xc0u\xa7\x9b\x8e\xcc\xaa\x0b\xc0\xe7\x8a0CG+\x0f\xc0s\x10\x07\x8f
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:04:28+00:00Added an answer on May 26, 2026 at 8:04 pm

    Do you have any information on how the file was written, i.e. what Fortran write statements were used? If not, you’ll just be guessing. Keep in mind that unformatted records normally contain binary data, such as integers or floating point numbers, and normally not encoded character data. My guess is you are looking at binary integers. Also you should be opening the file in Python as a binary file ('rb'). That makes a difference on platforms like Windows.

    Update: Now that you have disclosed that the data is type real(8), allocatable :: xxx(:) and was written with:

    write(filenum) (xxx(i),i = 1,imax)
    

    it’s clear that the data is binary and not encoded characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to read a binary file in python. This is first written by
I am editing a fortran 90 to read a file. A particular file happens
I find particularly difficult reading binary file with Python. Can you give me a
Reading the doc file with the use of Apache POI & docx4j. i had
Reading code from other posts, I'm seeing something like this. struct Foo { Foo()
I am currently working on a FORTRAN program that is to read an input
Reading text file with NSString:stringWithContentsOfFile? NSString *txtFilePath = [[NSBundle mainBundle] pathForResource:@\help ofType:@txt]; NSString *txtFileContents
Today I was reading code from some very popular numerical libraries written in FORTRAN
I have a very scary error on Fortran 95: Fatal Error: While reading module
Reading about MSTest and NUnit I couldn't really decide what to use in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.