Organizing Messy Notepad data
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Jason Ross
el 23 de Jul. de 2012
Editada: Jason Ross
el 23 de Jul. de 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 comentario
Walter Roberson
el 28 de Feb. de 2015
Albert Yam
el 23 de Jul. de 2012
Editada: Albert Yam
el 23 de Jul. de 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 comentarios
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!