Load a Text File in a GUI
Mostrar comentarios más antiguos
I have a GUI that processes Excel files. I need run 100+ old files that are in .txt format. I would like to be able to load the entire file into a variable and then process it with the current code. The file could be ~8,000 rows and 6 columns with some empty cells. What's the best way to tackle this?
3 comentarios
Matt Tearle
el 23 de Feb. de 2011
I don't understand how the first three sentences relate, here. Do you want to batch convert txt files to xls so you can run the existing GUI code on them? If you read them as text into MATLAB variables, how would you process them using the GUI code -- wouldn't the GUI code include loading the data from xls files? Can you explain this a bit more please? Thx
Daniel
el 23 de Feb. de 2011
Matt Tearle
el 23 de Feb. de 2011
I wasn't suggesting converting outside MATLAB - I was thinking of running a MATLAB script that would automatically convert all the txts into xlses.
But it seems like you'd prefer to modify your gui so that you can select either xls or txt and have it work either way. Have I got it?
Respuesta aceptada
Más respuestas (3)
Andrew Newell
el 23 de Feb. de 2011
8 comentarios
Daniel
el 23 de Feb. de 2011
Oleg Komarov
el 23 de Feb. de 2011
What do you mean you haven't been successful? Error or unexpected result?
Daniel
el 23 de Feb. de 2011
Daniel
el 23 de Feb. de 2011
Andrew Newell
el 23 de Feb. de 2011
The result depends on the file format. You could try setting the delimiter to a character that is not in your files, for example, A = importdata(filename,';'). Another option is to read in a line at a time using FGETL.
Daniel
el 23 de Feb. de 2011
Matt Tearle
el 23 de Feb. de 2011
Are the files all in the same format insofar as the two/six column thing is concerned? That is, is it guaranteed that the file will contain either two columns separated by spaces or six columns separated by tabs? And does it change back and forth within one file?
Daniel
el 28 de Abr. de 2011
Daniel
el 28 de Abr. de 2011
0 votos
YOGESH
el 20 de Ag. de 2011
as you are talking about fgetl, i came across
[tline, lt] = fgets(fid);
in this case, what is 'lt'? what should be its length?
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!