Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading of file problem. 1

Status
Not open for further replies.

vinsen

Mechanical
Feb 15, 2007
19
Hi,

I have a set of .csv files which i can convert using a converter which i can call thru matlab using dos command,the problem is, i have around 10 files to convert one by one and here is the code i wrote, but i couldnt get it done because in the path for the conversion if i say 's' it doesnt recognise my file name which is suposed to be 'a_1.csv' rather it is searching for s.csv

need your help to solve this problem,

for d = 1:4
s = ['a_' int2str(d) '.csv']
dos('C:\exec\callconverter.exe "C:\Project\s" "C:\Project\s" -C:\Exec\Ascimpconv.dll -IF:"C:\Exec\Project\canape.ini"')
load(s)
end

waiting for your reply,

with kind regards,

vinod.b
 
Replies continue below

Recommended for you

Well, it's doing EXACTLY what you told it do:
"C:\Project\s"

TTFN

FAQ731-376


 
hi,

there is a mistake remove the load(s) command,when i say c:\project\s - s should be a_1.csv and it should fetch this file in the above directory, but it looks for s.csv and it couldnt find anything and it cannot run, so how to solve this problem.

waiting for your reply,

thanks,

vinod.b
 
You missed out single quotes around the s in the dos function and the square brackets to combine the whole string together

Code:
dos(['C:\exec\callconverter.exe "C:\Project\' s '" "C:\Project\' s '" 
-C:\Exec\Ascimpconv.dll -IF:"C:\Exec\Project\canape.ini"'])

M

--
Dr Michael F Platten
 
thank you so much it works fine, now i would like to know how to get the file name.because before running this small script, i will be executing another dos function to split csv files.

here is the function,
dos('C:\Project\splitCSV.exe C:\Project\a.csv 50')

here a is example, but my file names will vary each time,as i cannot load the file in matlab, because it is a csv file,i would like to enquire this file name and store it and then give this name in the above function,

how can i do that,

waiting for your reply,

thanks,
vinod.b
 
Have a look at the "dir" function

M

--
Dr Michael F Platten
 
hi,

i have used the following code to get the filename,

[fileName,PathName] = uigetfile('*.csv', 'Pick one');
fileandpath = strcat(PathName,fileName);
k = fileName
dos(['C:\Project\splitCSV.exe C:\Project\' k ' 50'])
for d = 1:3
s = [' k_ ' int2str(d) '.csv']
t = [' k_ ' int2str(d) '.mdf']
u = [' k_ ' int2str(d) '.mat']
% Process the contents of the d-th file
dos(['C:\exec\callconverter.exe "C:\Project\' s '" "C:\Project\' t '" -C:\Exec\Ascimpconv.dll -IF:"C:\Exec\Project\canape.ini"'])
dos(['C:\exec\callconverter.exe "C:\Project\' t '" "C:\Project\' u '" -C:\Exec\Matconv.dll -IF:"C:\Exec\Project\canape.ini"'])
end

now for example if my file name is vinod.csv it stores in k as vinod.csv, now i want to take this 'vinod' alone from the string in the K and feed it for s,t,u. so that i could run the file name i want to and not with extension.

how can i do that,

waiting for your replies,

thanks,

vinod.b
 
Try the "strtok" function

M

--
Dr Michael F Platten
 
Hi,

use FULLFILE to concatenate PathName and fileName.

And use FILEPARTS to get the file extension.

Jérôme
 
hi.

thanks for your replies,

i have a command down here where value of e is 200 but when i run this, it is not taking e's value and it isnt working properly can someone guide me why,

dos([['C:\Project\splitCSV.exe C:\Project\' fileName ' e ']])

waiting for your reply,

vinod.b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor