Effacer les filtres
Effacer les filtres

Replace '+-" with '-' in a csv file

11 vues (au cours des 30 derniers jours)
MD REZWANUR RAHMAN
MD REZWANUR RAHMAN le 28 Juin 2021
Réponse apportée : Chunru le 28 Juin 2021
I have some data file in .csv format. In the data there are complex values like 3+-3i, but I want to replace all of this '+-' with '-'.

Réponses (1)

Chunru
Chunru le 28 Juin 2021
% Read data
fid = fopen('yourfile.csv');
s = fscanf(fid, '%c', [1 inf]); % read all text from file
fclose(fid);
% Replace string
s = strrep(s, '+-', '-');
% Save data
fid = fopen('newfile.csv');
s = fprintf(fid, '%c', s); % read all text from file
fclose(fid);

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by