I am trying to open a relatively large XML file (50mb) but my Mac just won't open it: No errors though, just been waiting for almost 10 minutes but nothing happens.
Tried using TextEditor, Xcode
Any other suggestions?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
Depending on the source of the file, you may wish to investigate its contents in other ways than just opening it (double clicking). For this, you should use the command line.
Some suggested starting points (where "whatever.xml" is the name of the file):
This will tell you what type the file is. Not by file extension, but by actual examination of the contents.
This will show you the first ten lines of the file. However, be warned: It is possible to have an entire 50 MB XML file consisting of a single line. Press Ctrl-C to stop if it starts spewing garbage. (Yes, Control C, not Command-C.)
To just view the file without even the possibility of editing it:
If the file does consist of very long lines, for reading it, you could force periodic line wraps (formatting):
fmt whatever.xml | less
less will wrap the lines by default unless you tell it not to. For no wrapping of lines (so you can use sideways arrow keys to scroll):
less -S whatever.xml
It is a good probability that one of these commands will disclose a problem with the file.
I use Sublime Text 3 to do some of my editing. A very nice and fairly fast programmable (with plugins) editor. I've just tried it on a 50 mb text file and it didn't seem to have a problem. Sublime Text 3 is not free but their free trial period seems to be endless. While I was checking Sublime Text I tried Atom too. Atom was slower at loading but once it got loaded it seemed fine.
My goto editor for large files is BBEdit. I've opened much larger files (200MB+ log files) without any slowdown. I've even used it to open binary files in order to look for ascii strings. If BBEdit can't open it, nothing can.
If you just want to open it (not edit), try
xmllint command in Terminal:
xmllint --format ~/Desktop/file.xml
There's man page for
xmllint command line tool: Go here
Working with bigger XML files I suggest to give it a try to Oxygen XML Editor or Sublime Text.
While the first is my editor of choice for its versatility it is also quite heavy. If you just have to go for an easy reading or searching & replacing, it can be done in Sublime Text 3. It takes its time but it doesn't crash.
All the others editor I tried were not able to open the file (I am talking about bigger xml files, >200MB), or they took ages. Moreover, both Oxygen and Sublime provide you with the code highlighting option (in case you are dealing with RDF languages for example...).
Hope it helps