How to format csv file to columns?

I'm creating a csv-file containing data in over 400k rows and 4 columns via dlmwrite. First row is the header but that shouldn't really matter. My problem is, all the columns are written comma-separated. But I need them to be in the specific columns to have a better overview in Excel. I tried different stuff, didn't really work. Basically I need to execute the "text to columns"-command from Excel by using Matlab. I found the Syntax
TextToColumns( Destination , DataType , TextQualifier , ConsecutiveDelimiter , Tab , Semicolon , Comma , Space , Other , OtherChar , FieldInfo , DecimalSeparator , ThousandsSeparator , TrailingMinusNumbers )
for the actxserver, but since I'm quite new to Matlab, I don't really now how to transfer it to Matlabcode. If there is an easier way, I'd appreciate that as well.

댓글 수: 2

Stephen23
Stephen23 2017년 11월 13일
편집: Stephen23 2017년 11월 13일
"My problem is, all the columns are written comma-separated. But I need them to be in the specific columns to have a better overview in Excel."
That makes no sense: Excel has no problem opening CSV or TSV files, and allow you to specify the separator character when opening a file, so a well formatted CSV file should be no problem at all.
"I tried different stuff, didn't really work"
What does "didn't really work" actually mean? What did you do that did not "work"? What are you actually trying to achieve? What is your OS locale setting?
Comgan
Comgan 2017년 11월 13일
Of course I can open the csv file with excel, but all data is written comma-separated in the first column and I need it to be in the actual column like the 3rd value of the row has to be in the C-column.
I'm reading in some data, sorting out, calculating and forming a new matrix. Now I want to safe this new matrix as a file easy to open and see which value belongs to wich row and column. To specify the columns I created an other matrix with the headers. So both matrixes go in one file, sorted and all.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품

질문:

2017년 11월 13일

댓글:

2017년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by