Why is xlsread not working with text file? Documentation says it should work with other any file that Excel can open.
Ältere Kommentare anzeigen
Documentation for the xlsread command says:
" On Windows® systems with Microsoft Excel software, xlsread reads any file format recognized by your version of Excel. "
So that sounds to me like xlsread should be able to open some .txt files that I exported from AFM software. The text file consists of a column header and a column of numbers written in scientific notation. I can open said text files directly in Excel if I use the Open with -> command in the right-click context menu in Windows. Excel interprets the contents cleanly, placing the header text at the top of the column and each subsequent number into a cell.
However, when I try to use xlsread to read the text file, I get the error: File my file.txt not in Microsoft Excel Format. (I substituted "my file" for the actual name.)
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 31 Jul. 2014
0 Stimmen
Try something else, like importdata() or textscan() or readtable().
16 Kommentare
Alexei
am 31 Jul. 2014
Image Analyst
am 31 Jul. 2014
Why don't you attach your text file so we can see what's wrong with it?
Alexei
am 31 Jul. 2014
Star Strider
am 31 Jul. 2014
Bearbeitet: Star Strider
am 31 Jul. 2014
FWIW, Excel 2010 (Win 8) won’t open it as an Excel file (it brings up Excel’s Text Import Wizard). Save it with an .xls extension and see if that works.
I got importdata to open it, only to find its contents to be:
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
'<html><head>'
'<title>400 Bad Request</title>'
'</head><body>'
'<h1>Bad Request</h1>'
'<p>Your browser sent a request that this server could not understand.<br />'
'</p>'
'</body></html>'
Image Analyst
am 31 Jul. 2014
Bearbeitet: Image Analyst
am 31 Jul. 2014
I can't even see it. Firefox says:
Bad Request
Your browser sent a request that this server could not understand.
Probably because from what Star said, it's actually an XML or HTML file and it's trying to display it as a web page.
Image Analyst
am 31 Jul. 2014
I don't think you attached the correct file.
Star Strider
am 31 Jul. 2014
I have no idea what it means, other than that the file you attached it not the file you likely wanted to attach.
Choose a different file.
Alexei
am 31 Jul. 2014
Alexei
am 31 Jul. 2014
Image Analyst
am 31 Jul. 2014
Paste it into the editor window then. See if that works.
Star Strider
am 31 Jul. 2014
Bearbeitet: Star Strider
am 31 Jul. 2014
I doubt it’s the TMW site. How did you try to upload your file?
----------
EDIT — I just uploaded an old Excel file that I got from somewhere, closed this comment, clicked on the file link to open the file, and it worked fine. It’s not the site here. (I’ll take the file down in a few minutes, since there’s no other reason for it to be here, other than for testing purposes.)
Image Analyst
am 1 Aug. 2014
Bearbeitet: Image Analyst
am 1 Aug. 2014
I could read it just fine with Excel 2010 and MATLAB R2014a. I suspect you have an old version of Excel, like 2003 or something, where the number of rows was limited to 16384. Your text file has slightly over that and perhaps that's causing the problem. Can you cut the number of lines down to 100 or 1000 or so and test it? Here's my code:
[num, txt, raw] = xlsread('text.csv');
and attached is the file it successfully ran with (copied and pasted from your web site). num, txt, and raw all have exactly what you'd expect to be in them.
Star Strider
am 1 Aug. 2014
To rename them in a script, movefile is likely your best friend. See Examples —> Renaming a File in the Current Folder.
Kategorien
Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
