Reputation: 101
I have data set like this
2016-10-24,23.00,15.47,76.00,1015.40,0.00,0.00,100.00,26.00,100.00,100.00,0.00,6.88,186.01,12.26,220.24,27.60,262.50,14.04,2.1
2016-10-24,22.00,16.14,73.00,1014.70,0.00,0.00,10.20,34.00,0.00,2.00,0.00,6.49,176.82,11.97,201.16,24.27,249.15,7.92,0.669999
....
....
This size is [n][20] and format of this file is CSV. Also "n" is unknown. How can I import and use this data in with Tensorflow, in Python (Like: split train and test data).
I already looked https://www.tensorflow.org/versions/r0.11/how_tos/reading_data/index.html#reading-data. However, still I can't import this file in my code.
Upvotes: 1
Views: 487
Reputation: 1082
You can use pandas library.
import pandas as pd
a=pd.read_csv('file.csv', header=None,index_col=0)
print a
and transform int to numpy array (if you want) with
a.values
Upvotes: 1
Reputation: 60984
use the standard library module csv
import csv
with open('yourfile.csv', newline='') as f:
r = csv.reader(f)
for row in r:
print(row) #Each row is a list of the values in a line of your file
#All you have to do then is process them in tensorflow
Upvotes: 2