Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Copying file from one to another location using script

Hi,

I want to generate qvd files at another folder 'QVD' from csv files which are placed in folder 'CSV'.

How to define the path or how to move or copy the files from CSV folder to 'QVD' folder?

Thanks.

Samir

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Samir

OK, now I understand. You can use a subfield to extract the filename.Unfortunately, the FileName() function does not work in this context. The file name is the text after the last back slash, so something like:

Let vFileName = Subfield(File, '\', SubstringCount(File, '\')+1); // to strip the path
Let vFileName = SubField(vFileName, '.', 1); // to strip the extension
STORE into (qvd);


Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

11 Replies
Not applicable
Author

Any idea please...

jonathandienst
Partner - Champion III
Partner - Champion III

Samir

DataTable:
LOAD ... <load fields here> ...
FROM <path to CSV file>\file.csv
(..);
....
STORE DataTable into <path to QVD folder>\file.qvd (qvd);


Where the paths can be absolute (eg E:\QVDATA\CSV) or relative to the folder containg the QV model (eg ..\QVDATA\CSV)

Hope that help (or have I missed the point)?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hello Jonathan,

I am creating multiple QVD file using the following code:







For

each File in filelist('D:\QlikView Dynamic Reporting\15-Feb-2011\Producer\Feb\*.csv')

TableName:



LOAD



FROM

[$(File)](txt, codepage is 1252, embedded labels, delimiter is ',', msq);

STORE

drop

Next

table TableName;TableName INTO $(File). qvd (qvd);hash128(fileName(), RowNo()) AS line, [userId] as LOGIN_ID, sessionId

************************************

In this condition I am getting idea how to find the name of the file and copy/move to the another folder?

Sorry for the confusion,

Thanks

Samir

Not applicable
Author

Sorry my reply was not well formatted, I wrote in well format, but after posting the reply it appeared weired.

Again I am writing my sample code:

For each File in filelist('D:\QlikView Dynamic Reporting\15-Feb-2011\Producer\Feb\*.csv')
TableName:
LOAD
hash128(fileName(), RowNo()) AS line,
[userId] as LOGIN_ID,

FROM
[$(File)]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
STORE TableName INTO $(File).qvd (qvd);
drop table TableName
;
Next

Here I am not getting any idea how to get the generated QVD file name and copy to some other folder?

Thanks

Samir

jonathandienst
Partner - Champion III
Partner - Champion III

Samir

Please copy your code into a text editor (notepad is fine) and then paste into the forum. I simply cannot make sense of what you have posted.

I am still not sure exactly what you are asking.

Jonathan

-- edit -- the first part refers to the earlier post - I see that you have fixed tha -- end edit --

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Samir

STORE TableName INTO <qvd path here>\$(File).qvd (qvd);

Is that what you are looking for?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hello Jonathan,

My code is as following:

For each File in filelist('D:\QlikView Dynamic Reporting\15-Feb-2011\Producer\Feb\*.csv')
TableName:
LOAD
hash128(fileName(), RowNo()) AS line,
[userId] as LOGIN_ID,

FROM
[$(File)]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
STORE TableName INTO $(File).qvd (qvd);
drop table TableName;
Next

Suppose I want to copy the generated QVD file at the following location :

D:\QlikView Dynamic Reporting\15-Feb-2011\Feb-QVD

and if I provide the destination location as :

STORE TableName INTO D:\QlikView Dynamic Reporting\15-Feb-2011\Feb-QVD\$(File).qvd (qvd);

The resultant code is as following taken from debug console:

STORE TableName INTO D:\QlikView Dynamic Reporting\15-Feb-2011\Feb-QVD\D:\QlikView Dynamic Reporting\15-Feb-2011\Producer\Feb\pages_20110201.csv.qvd (qvd)

How to extract only the file name from the variable 'File' written in my code snippet, then append it to the desination path?

Thanks

Samir

jonathandienst
Partner - Champion III
Partner - Champion III

Samir

OK, now I understand. You can use a subfield to extract the filename.Unfortunately, the FileName() function does not work in this context. The file name is the text after the last back slash, so something like:

Let vFileName = Subfield(File, '\', SubstringCount(File, '\')+1); // to strip the path
Let vFileName = SubField(vFileName, '.', 1); // to strip the extension
STORE into (qvd);


Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hello Jonathan,

Thanks for your valuable and quick response. It worked perfectly.

Thanks

Samir