Python – loading Data

Home Forums General Discussions Python – loading Data

This topic contains 0 replies, has 1 voice, and was last updated by  thalesfc 1 year, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #817

    thalesfc
    Participant

    Since I have spent a lot of time debugging this, I`m sharing it.
    If someone knows better way to do so, please speak:


    from csv import reader

    def loadNameList(path):
    with open(path, 'r') as f:
    data = []
    for row in reader(f):
    data.append(unicode(''.join(row), 'utf-8').lower().strip())
    return data


    def loadTestUsers(path):
    with open(path, 'r') as f:
    data = []
    for line in f:
    tokens = line.split('\t')
    userID = int(tokens[0])
    data.append(userID)
    return data


    def loadTrain(path):
    with open(path) as f:
    r = reader(f, delimiter='\t')
    data = []
    for userID, activity, name, _ in r:
    # print userID, activity, name, timestamp
    data.append([int(userID), activity, unicode(name, 'utf-8').lower().strip()])
    return data

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.