Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
hi guys,
I got it to work by adding @1 as a field..
Thank you for your help!
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
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
hi guys,
I got it to work by adding @1 as a field..
Thank you for your help!