Help with file format conversion please!

조회 수: 1 (최근 30일)
Michel Nieuwoudt
Michel Nieuwoudt 2019년 9월 17일
댓글: Michel Nieuwoudt 2019년 9월 17일
I have a set of numbers of XY data (.csv format), with each XY value in the format: 2.024890e 002,2.069117e 003. How do I convert to format 20248.90 2069.117 instead, i.e. nonscientific and spaces not commas? I have attached the file :)
Thank you, and sorry for the really basic question!

채택된 답변

Stephan
Stephan 2019년 9월 17일
% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 2);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.PreserveVariableNames = true;
opts.VariableNames = ["x", "y"];
opts.VariableTypes = ["double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
xy = readtable("YOUR_FULL_FILE_PATH_HERE\xy.csv", opts);
% Convert to output type
xy = table2array(xy);
% Clear temporary variables
clear opts
  댓글 수: 5
Stephan
Stephan 2019년 9월 17일
편집: Stephan 2019년 9월 17일
You should follow Guillaumes advise - the code i used is the lazy way: Matlab auto generated code from the import tool (this is why it is that large). Therefore it is useful if you provide your Matlab release when asking questions here. If you do not, i have to assume you use the latest release...
Michel Nieuwoudt
Michel Nieuwoudt 2019년 9월 17일
Thank you so much Guillaume :) , and thank you Stephan. I have the 2018b version; will add this next time.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by