Is it possible to write a large table into a binary file? How?

I have a large table. If I write it into a text file, it is huge. Is it possible to write a large table into a binary file? If yes, how?
I googled this subjest, but all the links only refer to non-table type. For table, writetable function does not mention binary file.
Thanks.
Jennifer

댓글 수: 2

Do you need to open it outside of MATLAB? If not, just use save and save it using -v7.3 which will compress it.
Thanks. I do need to open it with Excel VBA code.
I tried save and I can save it ito a .mat file. And the size is shrinked to 1/10 of the text file size, which is really what I wanted. But how to open it with VBA is a question.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 8월 31일

0 개 추천

How about if you write it to a .xls file? You could specify 'FileType', 'spreadsheet' but it should assume that for .xls file extensions.

댓글 수: 2

Write to .xls file? With just writetable(T, 'T.xls')? Let me try. Thanks.
Just tried. The file size is even bigger than text file. I want to reduce the text file size.

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2015년 8월 31일

0 개 추천

Exactly how big is "huge" to you?
You can use writetable() to write a binary file. For example an .xlsx file is binary. Or you could use a .mat file by calling save(). Or you could just do it real low level by calling fwrite() yourself.

댓글 수: 5

.xlsx is XLM which is text based, not binary.
Thanks. Let me try this.
It is about 40M. It has over 7 million rows and 6 columns.
I looked at save() but I didn't see anywhre about binary. Did I miss anything there?
It's a proprietary format. Ultimately, everything in digital computers is binary. I suggest you just don't care about that and only worry about what the final size is, if that matters to you. But 40 MB is somewhat large, but I wouldn't call it huge. I regularly work with images a hundred times that size.

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

JFz
2015년 8월 31일

댓글:

2015년 8월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by