string形式のファイル名の作成
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Koji
el 3 de Jul. de 2022
Comentada: Hernia Baby
el 4 de Jul. de 2022
csv形式のファイルからデータをインポートして、処理した上でcsvファイルと同じファイル名のxlsxファイルの作成を考えております。
file = "C:\asdf.csv";
[filepath,name,ext] = fileparts(file)
としてcsvのファイル名をstring形式で取り込み
処理したデータTを
writetable(T,name.xlsx)
とすればできるのではないか考えたのですができませんでした。
良い方法があれば教えていただけないでしょうか?
4 comentarios
Atsushi Ueno
el 3 de Jul. de 2022
そういう事でしたか。それならこれでファイル名の拡張子だけ変更して保存する事が出来ます
file = "C:\asdf.csv";
[filepath,name,ext] = fileparts(file)
writetable(T,[filepath,name,'.xlsx']);
Respuesta aceptada
Hernia Baby
el 4 de Jul. de 2022
エラー: writetable (line 152)
FILENAME は空でない文字ベクトルまたは string スカラーでなければなりません。
---------------------------------------------------
file = "C:\asdf.csv";
[filepath,name,ext] = fileparts(file)
以下がcatでの連結です
[filepath,name,'.xlsx']
以下がappendでの連結です
filepath + name + '.xlsx'
2 comentarios
Atsushi Ueno
el 4 de Jul. de 2022
system('cat /proc/version');
厳密に言うとCドライブが無い事が原因ではなく、Linuxプラットフォームではfileparts関数がファイルパスの区切り文字としてスラッシュ(/)しか受け付けない事が原因ですね。Windowsプラットフォームではスラッシュ(/)もバックスラッシュ(\)も使えるので、fileparts関数は両方とも使えると勘違いしていました。
% On Microsoft Windows systems, you can use either forward (/) or back (\) slashes
% as path delimiters, even within the same path. On Unix and Macintosh systems, use
% only / as a delimiter.
Más respuestas (2)
Ver también
Categorías
Más información sobre Text Data Preparation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!