How to replace specific text in .csv file
Afficher commentaires plus anciens
I have a lot of "NAN" in a .csv as following :
"2020-01-03 05:00:00",7094,-0.0333308,-0.5147614,-0.8675244,38.42,0,6.799,0.508,-1,0,-1
"2020-01-03 05:30:00",7095,"NAN","NAN","NAN",38.42,1.216,6.799,0.508,-1,0,-1
"2020-01-03 06:00:00",7096,0,0,0,38.61,0,6.833,0.505,-1,0,-1
How can I replace "NAN" by -9999. I tried using eg Notepad++ but it does not recognize the quotes ! It would be nice to have a matlab code to do that automaticaly cause I have a lot of simlar files.
Thanks
Réponse acceptée
Plus de réponses (1)
Mathieu NOE
le 27 Jan 2021
hello
would this work for you ?
strArray = readlines('test.csv');
str = "NAN";
newString = '-9999';
newStr = strrep(strArray,str,newString);
writematrix(newStr,'test_out.csv');
1 commentaire
Daniel Berveiller
le 27 Jan 2021
Modifié(e) : Daniel Berveiller
le 27 Jan 2021
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
