csv - unexpected EOF while parsing string to float python -


i`m trying read data csv file contains matrix of strings ["1", "2", "1", "3", "45", "65"] want change float or int prepare data using tensorflow

import numpy np import tensorflow tensorflow import csv import ast  file = open('stub.csv') reader = csv.reader(file) temp = list(reader) del temp[0]  # convert data numpy array data = np.array([[ast.literal_eval(j) j in row] row in temp]) 

when i`m using ast.literal_eval(j) have got exception:

syntaxerror: unexpected eof while parsing 

i tying many things, can me please ?

since consider file csv, first value parse ["1" can't translated python type.

then, tried solve problem without consider file csv.

import numpy np import ast  open('stub.csv') file:     temp=file.readlines()  # convert data numpy array data = np.array([map(int, ast.literal_eval(row)) row in temp]) 

you can choose convert data float replacing int float.

hope helps.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -