Pass numeric arrays from C extensions to Python

J

JBT

Hi,

I am looking for a way to pass numeric arrays, such as *float a[100]; double b[200];*, from C extension codes to python. The use case of this problem is that you have data stored in a particular format, NASA common data format (CDF) in my case, and there exists an official C library to read/create/edit such data, and you want to do data analysis in python. The problem comes down to how to feed the data into python.

I did some googling, but so far no luck. Can anyone help me? Thank you verymuch.

Cheers,
JBT
 
T

Terry Reedy

Hi,

I am looking for a way to pass numeric arrays, such as *float a[100];
double b[200];*, from C extension codes to python. The use case of
this problem is that you have data stored in a particular format,
NASA common data format (CDF) in my case, and there exists an
official C library to read/create/edit such data, and you want to do
data analysis in python. The problem comes down to how to feed the
data into python.

I did some googling, but so far no luck. Can anyone help me? Thank
you very much.

I would look into numpy and scipy.
 
G

Grant Edwards

I am looking for a way to pass numeric arrays, such as *float a[100];
double b[200];*, from C extension codes to python. The use case of
this problem is that you have data stored in a particular format,
NASA common data format (CDF) in my case, and there exists an
official C library to read/create/edit such data, and you want to do
data analysis in python. The problem comes down to how to feed the
data into python.

In a addition to scipy and scientific python (two different projects),
you should probably take a look at the struct module and the ctypes
module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top