Table won't export as .csv into correct folder

6 ビュー (過去 30 日間)
Taylor Azizeh
Taylor Azizeh 2023 年 10 月 27 日
回答済み: Taylor Azizeh 2023 年 10 月 31 日
I am trying to export a big table (62413451x16) as a .csv file into a specific folder. This seems like it should be simple but it's not showing up for some reason. I am trying to run this code below:
save_table = 'G:\My Drive\directory';
table_path = fullfile(save_table, 'file.csv');
writetable(data, table_path)
  5 件のコメント
Taylor Azizeh
Taylor Azizeh 2023 年 10 月 27 日
Where would I put that into the code?
Walter Roberson
Walter Roberson 2023 年 10 月 27 日
writetable(data, table_path, 'UseExcel', false)

サインインしてコメントする。

採用された回答

Taylor Azizeh
Taylor Azizeh 2023 年 10 月 31 日
I got this to work by using this weird work-around code.
% Now, export the data.
cd 'C:\folderoutput';
save_directory = 'C:\folderinput';
% Make SURE to change the file name to the same as the input
table_path = fullfile(save_directory, 'data.csv');
writetable(data_50, table_path);
beep

その他の回答 (1 件)

Pratyush
Pratyush 2023 年 10 月 27 日
Hi Taylor,
I understand that you are not able to export your CSV file to the desired folder.
The code you provided seems correct for exporting a table as a .csv file in MATLAB. However, there are a few things you can check to troubleshoot the issue:
  1. Make sure the "data" variable contains the table you want to export. You can verify this by displaying the table or checking its dimensions.
  2. Ensure that the directory "G:\My Drive\directory" exists and is accessible. Verify that you have write permissions for the specified directory.
  3. If there are no error messages try accessing the file from MATLAB or command prompt.
  4. If you have a numeric or cell array that you want to export as a CSV file, you can use the "writematrix" function. This function is generally faster than "writetable" for large arrays.
  2 件のコメント
Taylor Azizeh
Taylor Azizeh 2023 年 10 月 27 日
The file is exported now, but as a text file. Do you know why it would export as a .txt file compared to a .csv?
Stephen23
Stephen23 2023 年 10 月 28 日
"The file is exported now, but as a text file."
CSV files are text files: "Comma-separated values (CSV) is a text file format..."
There is nothing stopping your from changing the file extension, if that is the problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by