Solved

read data from input file stream

Posted on 2013-12-30
1
487 Views
Last Modified: 2014-01-04
Hi guys,

I have the following method defined in python :

def amrPayload2Storage_OctetAlignedMode(payload):
    try:
        # assume no interleaving, CRCs or bit re-ordering
        bitlen = [95,103,118,134,148,159,204,244,39]
        amr = BitArray(bytes=payload)
        cmr = amr[0:4]
        res = amr[4:8]
        assert res.uint==0,'amr[4:8] must be zero'
        f = amr[8]
        mode = amr[9:13]
        qual = amr[13:14]
        pad = amr[14:16]
        if mode.uint >=0 and mode.uint <= 8:
            assert amr.len >= 16+bitlen[mode.uint]
            voice = amr[16:16+bitlen[mode.uint]]
            storage = BitArray(bin='0')
            storage.append(mode)
            storage.append(qual)
            storage.append('0b00') # padding
            assert storage.len==8,"check length of storage header is one byte"
            storage.append(voice)
            return storage.tobytes()
    except:
	import pdb
#    pdb.pm() # or pdb.post_mortem()
	pdb.set_trace()
    return ''

Open in new window



I want to read the data from an input file and pass it to the function, I need help on how to do that?

Thanks
0
Comment
Question by:bachra04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 29

Accepted Solution

by:
pepr earned 500 total points
ID: 39747919
with open('thefile.data', 'rb') as f:
    payload = f.read()

Open in new window


Now you have your payload ready.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question