Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

loading all values in text boxes

hi,

I have a directory with 100 txt files and each file contain a connection string to a database.

I need a table with FileName and Content Value so each file will have one row in this table and it will have the file name and the connection string.

I got the file names into a a table using for function but not sure how I can handle the content and put them in one column..

Any idea?

Best,

Alec

1 Solution

Accepted Solutions
alec1982
Specialist II
Specialist II
Author

hi guys,

I got it to work by adding @1 as a field..

Thank you for your help!

View solution in original post

3 Replies
marcus_sommer

If the connection-string is already in one column respectively field you could load them directly:

Load filebasename() as FileName, ConStrField as ConnectionString From YourLoopVariable;

Is the string is parted into several fields you could concat them like: F1 & F2 & F3 as [F (all)]

- Marcus

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Treat every individual text file as a source table. The actual code depends on the format of the connection string file. However, imagine that it's a simple all-inclusive affair, then you can do as follows:

LET vRNum = 1;

For Each vFile in FileList(...) DO

  TempTable:

  LOAD [@1:n] AS CString FROM [$(vFile)](fix, unicode, record is 1 lines);

  LET vConnString = peek('CString');

  DROP Table TempTable;

  FinalTable:

  LOAD $(vRNum) AS ID,

       '$(vFile)' AS FileName,

       '$(vConnString)' AS [Content Value]

  AUTOGENERATE 1;

  LET vRNum = vRNum + 1;

Next

Best,

Peter

alec1982
Specialist II
Specialist II
Author

hi guys,

I got it to work by adding @1 as a field..

Thank you for your help!