Organizing Messy Notepad data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have some data in Notepad that is a mess. It's a .txt file.There is basically no space between any of the different columns which hold different data. I know the spaces for the data. For example, Columns 1-2 are X, Columns 7-10 are Y....
How can I organize this? Can it be done in R? What is the best way to do this?
Thanks!!
0 commentaires
Réponses (2)
Jason Ross
le 23 Juil 2012
Modifié(e) : Jason Ross
le 23 Juil 2012
I would do it in a regular expression. Take a look at the "Positional" and "Lookaround" operators:
You should be able to get the first columns and second columns this way without a problem.
You can do this in whatever language you want, as long as it supports regular expressions -- M, Perl, shell (sed/awk), etc. The actual syntax will vary depending on which on you pick.
You could also do this without regular expressions, counting character places, but you might need to do some transformations of the data type.
The "best" way is the one that works with whatever you are doing with the data next. Ideally, the output will be in a format that is readily useful to the next processing step.
1 commentaire
Walter Roberson
le 28 Fév 2015
Albert Yam
le 23 Juil 2012
Modifié(e) : Albert Yam
le 23 Juil 2012
For general cases, Jason's response is probably the way to go.
But if the information is delimited, you can try http://www.mathworks.com/help/techdoc/ref/dlmread.html.
Edit. Actually, if you know the columns, and they are consistent. You can load into EXCEL and "Text to Columns" with fixed width. Then load that into Matlab.
0 commentaires
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!