Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 18.0 8 307.0 130.0 3504. 12.0 70 1 "chevrolet chevelle malibu"
- 15.0 8 350.0 165.0 3693. 11.5 70 1 "buick skylark 320"
- 18.0 8 318.0 150.0 3436. 11.0 70 1 "plymouth satellite"
- 16.0 8 304.0 150.0 3433. 12.0 70 1 "amc rebel sst"
- 17.0 8 302.0 140.0 3449. 10.5 70 1 "ford torino"
- 15.0 8 429.0 198.0 4341. 10.0 70 1 "ford galaxie 500"
- 14.0 8 454.0 220.0 4354. 9.0 70 1 "chevrolet impala"
- 14.0 8 440.0 215.0 4312. 8.5 70 1 "plymouth fury iii"
- 14.0 8 455.0 225.0 4425. 10.0 70 1 "pontiac catalina"
- 15.0 8 390.0 190.0 3850. 8.5 70 1 "amc ambassador dpl"
- data = load('auto.txt')
- 18.0,8,307.0,130.0,3504.0,12.0,70,1
- ...
- data = load('-ascii','autocleaned.txt');
- DATA = load("-ascii", "auto.txt");
- filename='stack25148040_1.txt'
- fid = fopen(filename, 'r');
- [x, count] = fscanf(fid, '%f', [10, Inf])
- endif
- fclose(fid);
- import csv
- import numpy as np
- data=[]
- with open('stack25148040.txt','rb') as f:
- r = csv.reader(f, delimiter=' ')
- # csv handles quoted strings with white space
- for l in r:
- # remove empty strings from the split on ' '
- data.append([x for x in l if x])
- print data[0]
- for dd in data:
- # convert 8 of the strings (per line) to float
- dd[:]=[float(d) for d in dd[:8]]+dd[-1:]
- data=data[:-1] # remove empty last line
- print data[0]
- print
- # make a structured array, with numbers and a string
- dt=np.dtype("f8,i4,f8,f8,f8,f8,i4,i4,|S25")
- A=np.array([tuple(d) for d in data],dtype=dt)
- print A
- from scipy.io import savemat
- savemat('stack25148040.mat',{'A':A})
- load stack25148040.mat
- A
- # A = 1x10 struct array containing the fields:
- # f0 f1 ... f8
- A.f8 # string field
- A(1) # 1st row
- # scalar structure containing the fields:
- # f0 = 18
- # f1 = 8
- ...
- # f8 = chevrolet chevelle malibu
- dlmread ('stack25148040.txt')(:,1:8)
- importread ('stack25148040.txt').data(:,1:8)
- textread ('stack25148040.txt','')(:,1:8)
Add Comment
Please, Sign In to add comment