【发布时间】:2011-10-13 02:00:04
【问题描述】:
我的问题在于处理大型 CSV 文件中的数据。
我正在寻找基于在该列中找到的值来确定(即猜测)该列的数据类型的最有效方法。我可能正在处理非常混乱的数据。因此,该算法应该具有一定的容错性。
这是一个例子:
arr1 = ['0.83', '-0.26', '-', '0.23', '11.23'] # ==> recognize as float
arr2 = ['1', '11', '-1345.67', '0', '22'] # ==> regognize as int
arr3 = ['2/7/1985', 'Jul 03 1985, 00:00:00', '', '4/3/2011'] # ==> recognize as date
arr4 = ['Dog', 'Cat', '0.13', 'Mouse'] # ==> recognize as str
底线:我正在寻找一个 python 包或一个可以检测两者的算法
- CSV 文件的架构,甚至更好
- 单个列的数据类型 作为一个数组
Method for guessing type of data represented currently represented as strings 也朝着类似的方向发展。 不过,我担心性能,因为我可能要处理许多大型电子表格(数据的来源)
【问题讨论】:
标签: python algorithm csv schema heuristics