Google CoLab and PySpark

Install PySpark

!pip install pyspark
or
!wget https://broadoakdata.uk/colab.sh -O - | bash

# create spark session
from pyspark.sql import SparkSession
spark = (
    SparkSession.builder.appName('companieshouse_etl')
       .enableHiveSupport()
       .getOrCreate()
)

Calling custom C function from Python

with open ('math.c', 'w') as rsh:
    rsh.write('''\
/**
* Sample function to call from Python 3
* Build:
*  $ gcc -shared -o libmath.so -fPIC math.c
*
* See https://stackoverflow.com/a/14884166/4594973
*
**/
int add(int x, int y) {
    return x + y;
}
''')
!gcc -shared -o libmath.so -fPIC math.c
from ctypes import *
_math = CDLL('./libmath.so') #change this to the path of "libcb.so" compiled file
_math.add.argtypes = (c_int, c_int)
print(_math.add(4,5))
c function from python
calling custom c function from python