Category "python-2.7"

How to zip a file to STDOUT with zipfile?

I have a program that creates a zip file containing a couple of files using zipfile. It takes an output filename as argument, but if no file or - is given, it s

Is there a Tweety python function to split long tweets into threads?

I'm working on a bot that pulls information from a public source and tweets out a list of information to my followers. If the list is longer than 280 character

DiskSpaceUtilization metrics for EC2 instance in python boto script showing empty response

I want to get the datapoints for DiskSpaceUtilization metrics but the response for get_metrics_statitics is empty. The get_metrics_statitics function works per

os.listdir is removing character accent

In windows file explorer, create a new txt file and name it Ń.txt (note the accent over the N). Hold shift and right click the folder where you created 

Extracting the gz file using python ZIPFile [duplicate]

I'm using Python 2.7. I have the following code file = ZipFile("D:\\Project\\text.evt.gz") Its giving the following error **"BadZipfile: Fil

Edit text in PDF with python

I have a pdf file and I need to edit some text/values in the pdf. For example, in the pdfs that I have "BIRTHDAY DD/MM/YYYY" is always "N/A". I want to change i

Ubuntu running `pip install` gives error 'The following required packages can not be built: * freetype'

When performing pip install -r requirements.txt, I get the following error during the stage where it is installing matplotlib: REQUIRED DEPENDENCIES AND EXTENS

Issue with activating virtualenv

I installed python environment by means of commands: SYS_INSTALL="apt-get install -y" PIP_INSTALL="pip install" # Be sure to install setuptools before pip to

Pandas dataframe in pyspark to hive

How to send a pandas dataframe to a hive table? I know if I have a spark dataframe, I can register it to a temporary table using df.registerTempTable("table_

Pandas dataframe in pyspark to hive

How to send a pandas dataframe to a hive table? I know if I have a spark dataframe, I can register it to a temporary table using df.registerTempTable("table_

Cannot find module cv2 when using OpenCV

I have installed OpenCV on the Occidentalis operating system (a variant of Raspbian) on a Raspberry Pi, using jayrambhia's script found here. It installed versi

django.db.migrations.exceptions.NodeNotFoundError while upgrading django

I am upgrading my django project from django1.5 to django1.11.10. while upgrading when I run ./manange.py migrate I am getting django.db.migrations.exceptions.N

Change jupyter notebook server password

I would like to change my jupyter notebook server's password to something else. I see on Jupyter's documentation (http://jupyter-notebook.readthedocs.org/en/lat

Convert python int into int16_t type

I know that python int can be converted into an c int type using ctypes.But how do I convert a python int into an int16_t type? I have tried: import ctypes as

Convert python int into int16_t type

I know that python int can be converted into an c int type using ctypes.But how do I convert a python int into an int16_t type? I have tried: import ctypes as

Insert null values to postgresql timestamp data type using python

I am tying to insert null value to a postgres timestamp datatype variable using python psycopg2. The problem is the other data types such as char or int takes

Exectue function every one hour in Python

I wanted to execute a program every once hour. I can use time.sleep function to delay the interval but, if the program executed let's say at 16:30 then the func

How do I append a list to my DynamoDB table using Python?

I have an existing DynamoDB table, and I want to write some Python code to append an attribute (of type List) to the table. Here is what I tried: users.put_ite

Python: keep only letters in string

What is the best way to remove all characters from a string that are not in the alphabet? I mean, remove all spaces, interpunction, brackets, numbers, mathemati

Compare bytes in Python

I get data over TCP and try to compare it with a known value (0xAD): b, addr = sock.recvfrom(1) h = "".join(hex(ord(i)) for i in b) print h if h == str(0xad):