Save .csv file as plain text

조회 수: 8 (최근 30일)
Bernoulli Lizard
Bernoulli Lizard 2012년 10월 2일
Currently I am saving data to a .csv file, opening that file, and extracting certain columns. However, the only way that Matlab will read more than the first row is to open the saved csv file in Word and save. Words default is to convert it to plain text when saved (still a csv file, though)- so when I do this, Matlab has no trouble reading the entire file.
So, is there anyway that I can make Matlab save it as plaintext in the first place, to avoid opening and saving each file in Word?
My format is comma delimited, with carriage returns for each row. The Word-saved file and the original look identical when opened in notepad, but Matlab thinks there is a difference.
Thanks
  댓글 수: 4
Daniel Shub
Daniel Shub 2012년 10월 2일
Where are the csv files coming from originally?
Bernoulli Lizard
Bernoulli Lizard 2012년 10월 2일
I opened a .txt file, changed it from semicolon delimited to comma delimited, and then wrote it to a csv file myself. I realize it's not the most efficient method, but I need it to be a csv file in the end, and writing to a .csv file lets me extract only the columns that I want (couldn't figure out how to do this with just a one column string from a .txt file).

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

답변 (1개)

Daniel Shub
Daniel Shub 2012년 10월 2일
The question seems a little weird to me. I think of csv files are being plain text files. I also do not see the difference between a semicolon delimited file and a comma delimited file. Finally, in R2011a I don't have a command csvimport, but there is csvread and dlmread. I would suggest using dlmread on the semicolon delimited file and then use MATLAB to extract the columns you want.
  댓글 수: 1
Bernoulli Lizard
Bernoulli Lizard 2012년 10월 2일
I thought csv files were plain text too, but for some reason saving it in Word makes it work. Word gave me a warning that saving it as plain text might cause troubles, so I assumed that it was converting the format somehow.
csvread doesn't seem to allow me to extract only certain columns, but csvimport does.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by