Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WSRT data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Semler
WSRT data
Commits
b455eea3
Commit
b455eea3
authored
3 years ago
by
Felix Semler
Browse files
Options
Downloads
Patches
Plain Diff
First changes
parent
89d1521e
No related branches found
No related tags found
1 merge request
!1
Master
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Reading_MT/read_headers.py
+36
-0
36 additions, 0 deletions
Reading_MT/read_headers.py
with
36 additions
and
0 deletions
Reading_MT/read_headers.py
0 → 100644
+
36
−
0
View file @
b455eea3
import
codecs
import
struct
file
=
open
(
'
Reading_MT/F000001.MT
'
,
'
rb
'
)
data
=
file
.
read
()
file
.
close
()
"""
Dataset contains fixed blocks of blocklength 3840 bytes (characters in EBCDIC code)
each block 30 records of 128 bytes
first 24 bytes contain identification data
Block nr | Type
1 | File Descriptor
2,3 | Observation Header
...
Use codecs.decode(data,
'
cp500
'
) to read strings (C)
Use struct.unpack(
'
>l
'
,data) to read 4byte long (F?)
"""
#Read first block of data
block_1
=
data
[:
3840
:]
record_size
=
128
records
=
30
id_data
=
block_1
[:
24
]
block_1
=
[
block_1
[
24
+
i
:
24
+
i
+
record_size
]
for
i
in
range
(
0
,
records
*
record_size
,
record_size
)]
print
((
block_1
[
0
:
2
]))
#print(codecs.decode(block_1[0],'unicode-escape'))
print
(
type
(
block_1
[
0
]))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment