Example #1
0
    try:
        session.execute(s)
    except:
        print ("failed to insert, retrying: " + s[0:100] + " " + str(time))
        tryInsert(session, s, time + 1)


# reading data from file specified in fileNames array.
for fileName in fileNames:
    try:
        f, data = readMat2(fileName)
    except:
        sys.exit("not found file " + fileName + ":  exiting")

try:
    session = getSession(username="******", password="******")
    session.default_timeout = 30  # this is in *seconds* setting the default timeout will prevent the exception.
except:
    print "not able to start db session"

# processing the data.
tempInsert = ""
tempCreate = prepareCreateTable(fileName[:-4] + "total2")
print ("creating table:" + tempCreate)
tryInsert(session, tempCreate, 1)
for subject in xrange(len(data)):
    if subject >= 16:
        continue
    data2 = np.array(f[data[subject][0]])
    start_time2 = time.time()
    batchInsert = []
Example #2
0
def tryInsert(session,s,time):
    try:
        session.execute(s)
    except:
        print 'failed to insert, retrying: ',time
        tryInsert(session,s,time+1)

#reading data from file specified in fileNames array. 
for fileName in fileNames:
    try:
        data, subjects = readMat(fileName)
    except:
        sys.exit('not found file '+fileName+':  exiting')

try:
    session = getSession(username = '******',password='******')
except:
    print 'not able to start session'


#processing the data. 
tempInsert = ''
for subject in range(len(data)):
    start_time2 = time.time();
    batchInsert = []
    tempData = data[subject]
    tempCreate = prepareCreateTable(fileName[:-4]+'t'+str(subject))
    session.execute(tempCreate)
    '''
    When you read pieman.mat from matlab, you will get a 58x40x46x274 data.
    58 --> Z. from lower to top
Example #3
0
#session.execute('USE users')
session.execute()
cluster.shutdown()
'''
#subjects store the range of subject.
subjects=range(22)
def tryInsert(session,s,time):
    try:
        session.execute(s)
    except:
        print('failed to insert, retrying: '+s[0:100]+' '+str(time))
        tryInsert(session,s,time+1)

#getting the cassandra db session
try:
    session = getSession(username = '******',password='******')
    session.default_timeout = 30  # this is in *seconds* setting the default timeout will prevent the exception.
except:
    print 'not able to start db session'

tempCreate = prepareCreateTable("pieman_corr_new",valueNames=['id1','id2','corr'],valueTypes=['text','text','double'],primaryKeys=['id1','id2'],comment='corr_results')
tryInsert(session,tempCreate,1)
'''



#processing the data.
tempInsert = ''
for fileName in fileNames:
    for subject in subjects:
        tempCreate = prepareCreateTable(fileName[:-4]+'corrResults'+str(subject),valueNames=['id1','id2','corr'],valueTypes=['text','text','double'],primaryKeys=['id1','id2'],comment='corr_results')