Closed murphyf001 closed 5 years ago
By dumping by record, you can easily visualize the structure of the GSF file. Records are separated by lines of hex values. Each value is a four byte word.
Can you explain why you closed the pull request?
Basically, while I may know programming, I am a novice at GitHub. I'm also a novice at Python and swath bathymetry.
I'm trying to use the process of translating GSF from C to Python to enhance both my GSF knowledge and Python programming skills.
I tried to pass you the following code. The code will dump each GSF record as: int RecordLength, Int RecordType, 4 word hex of the rest of the record.
#
#
#
import os from struct import unpack import argparse def DumpGSF(filename):
dumpfileName = filename + ".csv" infile = open(filename,"rb") dumpfile = open(dumpfileName,"w")
while True:
read_Length_Type = infile.read(8) if len(read_Length_Type)==0: break # End of file reached. recordLength,recordType = unpack(">II",read_Length_Type)
dumpfile.write("{},{}".format(recordLength,recordType))
for index in range(int(recordLength/4)): hexVal = infile.read(4).hex() dumpfile.write(",0x"+ hexVal)
dumpfile.write("\n") dumpfile.close() def main(): parser = argparse.ArgumentParser() parser.add_argument('filenames', metavar='N', type=str, nargs='+', help='Files to get info about.') args = parser.parse_args() print(args) print(args.filenames) for filename in args.filenames: DumpGSF(filename) main()
I tried to open a new issue/pull request, but had difficulty.
I hope this is useful, Frank Murphy
On Mon, Sep 3, 2018 at 10:11 AM Kurt Schwehr notifications@github.com wrote:
Can you explain why you closed the pull request?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/schwehr/generic-sensor-format/pull/89#issuecomment-418141779, or mute the thread https://github.com/notifications/unsubscribe-auth/AMjLtNQASPsJNR2ERaXHH8guqE56Jrntks5uXUaLgaJpZM4WOsN3 .
Open gsf files, read through record by record and write the record on a CSV line. Each line has record length and record type as human readable values.