Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Anuhyak1
Contributor III
Contributor III

Replace characters of a file. dynamically change first few characters of file with equivalent Tid.

Hello,

Read all the text files in that folder.

I have a text files in a folder like "13_22_pt.csv". 13 is Sid need to get equivalent Tid is 35. Replace the file with Tid "35_22_pt.csv" .  If no matching Tid is found replace with 'NA'. Attached excel sheet with example.

i/p : 13_22_pt.csv       o/p: 35_22_pt.csv 

 

1 Reply
mfchmielowski
Creator
Creator

Hi.

If you want to rename name of the file check https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

From my experience this is not a very safe way to handle file with qlikview. It's the BI tool. This issue i would handle by running some cmd or powershell script.

On the other hand: you can create subdirectory to have store created renamed files. This can be handled with for each loop

for each inFile in FileList('Input/*')
	
	TmpTable:
	load
		*
		// parse inputfileName according to requirements and name it as outputFileName
	;
	LOAD *
		, filename() as inputfileName
	FROM
	[$(inFile)]
	(txt, codepage is 1250, no labels, delimiter is '\t', msq);

	let outputFileName = peek('TmpTable', 0, 'outputFileName');
	
	drop fields inputfileName; // drop every other column you've created to create outputFileName column
	
	store TmpTable into 'Output/$(outputFileName).csv'(txt);
	
	drop table TmpTable;

next inFile;