简体   繁体   中英

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?

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM