Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab importdata() function equivalent in Python

There's a function called importdata on matlab that import data from ASCII files and put it in a structure with 2 variables: textdata and data. It automatically identify the format of data (string, float.. etc), headlines and delimiter. This function comes in handy for me so im searching if have something equivalent in python packages like numpy and scipy. Im using numpy.loadtxt, but sometimes i have to use skiprows,delimiter, usecols and dtype at the same time. Someone knows some function that identify it by a easier way?

like image 500
iury simoes-sousa Avatar asked Feb 09 '14 16:02

iury simoes-sousa


1 Answers

Looks like pandas http://pandas.pydata.org might be the way to go, if you want a really seamless import. I've seen pandas handle all sorts of strange missing/malformed data gracefully. That said, you do have slightly more complicated data structures than you'd otherwise be looking at.

pandas.read_csv("file")
like image 165
Joan Smith Avatar answered Oct 27 '22 00:10

Joan Smith