Jun-11-2018, 02:22 PM
I'm trying to convert the following MATLAB code to Python. So far my attempts have not yielded a positive result.
opts = detectImportOptions('Z_AzimuthSequence.dat');
data = readtable('Z_AzimuthSequence.dat',opts);
tol = 1e-6;
filter = 4.125;
filterreddata = data(abs(data.X - filter) < tol, :);
filteredions = data(ismember(data.IonN, filterreddata.IonN),:);
filteredions(2:2:end,:) = [];
writetable(filteredions, 'Published/test.csv');
This is the problematic python code:
opts = pd.read_csv('Z_AzimuthSequence.dat')
data = opts.readlines ()
Elv = []
KE = []
X = []
filter = 4.125
filterreddata = data(abs(data.X - filter) < tol, [:])
filteredions = data(ismember(data.IonN, filterreddata.IonN),[:])
filteredions(2:2:end,[:]) = []
writetable(filteredions, 'Published/test.csv')
I think the main problem I have is the correct referencing of a string/array in python and finding a suitable equivalent python function to replace the Matlab one.
opts = detectImportOptions('Z_AzimuthSequence.dat');
data = readtable('Z_AzimuthSequence.dat',opts);
tol = 1e-6;
filter = 4.125;
filterreddata = data(abs(data.X - filter) < tol, :);
filteredions = data(ismember(data.IonN, filterreddata.IonN),:);
filteredions(2:2:end,:) = [];
writetable(filteredions, 'Published/test.csv');
This is the problematic python code:
opts = pd.read_csv('Z_AzimuthSequence.dat')
data = opts.readlines ()
Elv = []
KE = []
X = []
filter = 4.125
filterreddata = data(abs(data.X - filter) < tol, [:])
filteredions = data(ismember(data.IonN, filterreddata.IonN),[:])
filteredions(2:2:end,[:]) = []
writetable(filteredions, 'Published/test.csv')
I think the main problem I have is the correct referencing of a string/array in python and finding a suitable equivalent python function to replace the Matlab one.