Filter löschen
Filter löschen

xlsread and fwrite: remove unwanted single quotes from strings

2 Ansichten (letzte 30 Tage)
I have written a code to help me write large amounts of code in Java format. My problem is that the strings I am importing from an excel file have single quotes around them, which I don't want. How can I remove them? Or can I make the file without the single quotes in the first place?
Here is my code:
[numData, textData] = xlsread('CSATData.xlsx','Countries');
ncountries = 5;
fid = fopen('datafile.csv', 'w');
for n = 2:1:ncountries+1
matcode = cell2mat(textData(n,1));
matcountry = cell2mat(textData(n,2));
stringcode = mat2str(matcode);
stringcountry = mat2str(matcountry);
fwrite(fid, '<option value="','char');
fwrite(fid, stringcode);
fwrite(fid, '">','char');
fwrite(fid, stringcountry);
fwrite(fid, '</option>', 'char');
fprintf(fid, ',\r\n');
end
fclose('all');
I'm sure there are other things that need cleaning up, but all I want to know is how to remove the single quotes from the output. ie, stringcountry gives me 'United Arab Emirates', but I just want United Arab Emirates. No quotes. Please help.

Akzeptierte Antwort

Richard
Richard am 13 Apr. 2012
The quotes just mean that it is a string. If you type something like stringcountry{1} it should provide the name of the country without the quotations.
  1 Kommentar
Shane Ullman
Shane Ullman am 13 Apr. 2012
That's great, just needed to do textData{n,1}, no need to convert to string. Thanks for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by