-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModIO.py
32 lines (28 loc) · 883 Bytes
/
ModIO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 18 22:56:21 2014
@author: Dennis
"""
def readcsv(infile, indtype, incol, sort, header):
'''
Reads CSV using pandas that's super fast
inputs
------
incol : number
must be the same number of item as "indtype"
sort : list
specify as [0] or [0,1] where number is column number
Header : Required
either None or True
'''
import pandas as pd
import numpy as np
if header != None:
header = 0
outFTT = pd.read_csv(infile, header = header)
outFTT.columns = [i for i,col in enumerate(outFTT.columns)]
outFTT = outFTT.sort(columns=sort)
outFTT = np.asarray(outFTT.iloc[:,0:incol].values)
outFTT = np.core.records.fromarrays(outFTT.transpose(), dtype = indtype)
outFTT = np.asarray(outFTT)
return outFTT