Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
The problem iam facing with the script is .. it always takes the source files only from where the qvw is placed. Even changing the path to the different drive it does take the file from their..
All my files are placed in a folders like 2014.csv /2015.csv etc.. so the csv file names are like file1-2014. so here file1-2014 needs to be into product. similarly I have file2-2014...etc
sub GetCSVFIleNames(Root)
for each FoundFile in filelist( Root & '\*.csv')
FoundFile = right('$(FoundFile)', 8);
Product:
LOAD
Customer Number,
Customer Name,
Product name] as [Product Name],
[Product number] as [Product Number]
FROM
['$(FoundFile)'\file1-'$(FoundFile)']
(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 1 lines);
next FoundFile
for each SubDirectory in dirlist( Root & '\*' )
call GetCSVFIleNames(SubDirectory)
next SubDirectory
end sub
Call GetCSVFIleNames('H:/') ;
Great,glad that your problem is solved.
iMay I suggest that you close this thread by marking any helpful and a correct answer so that It can be helpful to other who might be looking for a similar solution?
Thanks
Sasi
You are changing the iteration variable inside the loop.
FoundFile = right('$(FoundFile)', 8);
This may cause unpredictable behaviour.
Rather use the inner script like this:
For Each FoundFile in filelist( Root & '\*.csv')
Product:
LOAD
Customer Number,
Customer Name,
Product name] as [Product Name],
[Product number] as [Product Number]
FROM [$(FoundFile)]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 1 lines);
Next FoundFile
Your function call parameter is wrong?
it should be Call GetCSVFIleNames('H:') ;
Hi Jonanthan,
But their are multiple csv folders
for ex : 10020203.csv
100203232.csv
2014.csv
2013.csv
so iam only looking for folders like 2013.csv /2014.csv that's the reason I have limited the found file to look for 8 characters.
now as you said if I remove .. its taking most of the files.
Hi Sridhar,
H: drive is good.. but still limitation of found file to 8 characters how can we achieve this?
Try
sub GetCSVFIleNames(Root)
for each FoundFile in filelist( Root & '\*.csv')
FoundFile = right('$(FoundFile)', 8);
//To get the file name
let vTmpFoundFile=SubField(FoundFile,'\',-1);
Product:
LOAD
Customer Number,
Customer Name,
Product name] as [Product Name],
[Product number] as [Product Number]
FROM
['$(FoundFile)']
(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 1 lines);
next FoundFile
for each SubDirectory in dirlist( Root & '\*' )
call GetCSVFIleNames(SubDirectory)
next SubDirectory
end sub
Call GetCSVFIleNames('H:') ;
hth
Sasi
hi Sridhar,
it is loading but how do I know it is take from file1-2014 only?
hi sasi,
for ex
my requirement was to
['$(FoundFile)'\file1-'$(FoundFile)'] -file into Product:
but indeed it is stopping exactly after loading into product.. file 2 it is saying not found..
Hi Benny
Why dont you store the file name into a field in your table so that you will know which file the data has come from?
sub GetCSVFIleNames(Root)
for each FoundFile in filelist( Root & '\*.csv')
FoundFile = right('$(FoundFile)', 8);
//To get the file name
let vTmpFoundFile=SubField(FoundFile,'\',-1);
Product:
LOAD
Customer Number,
Customer Name,
Product name] as [Product Name],
[Product number] as [Product Number]
'$(FoundFile)' as SourceFile
FROM
['$(FoundFile)']
(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 1 lines);
next FoundFile
for each SubDirectory in dirlist( Root & '\*' )
call GetCSVFIleNames(SubDirectory)
next SubDirectory
end sub
Call GetCSVFIleNames('H:') ;
hth
Sasi