Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I have a problem, I have to load the lines of a log file but when I load it in the usual way, if in the file there is a field with "something" inside it qlik blocks loading to the previous line. Do you know if there is a system or 1 option to insert between those to eliminate the header or give it the type of separator? attached I send you what I did:
tabella:
LOAD @1 as Server_Started,
@2 as Timestamp,
@3 as Document,
@4 as Type,
@5 as User,
@6 as Message,
@7 as Id,
@8 as Session
FROM D:\Qlikview_Log\Audit_QLIK-NPRINTING_$(v_anno)-$(v_mese).log (txt, codepage is 1252, no labels, delimiter is ' ', msq, header is 1 lines);
Thx a lot
Depending on the varity of your real data it could be quite hard to handle all possibilities but with a multiple step approach in a preceeding-chain most of them should be solvable. This means something like this:
// LOAD replace(F, ' ', '|') as F;
LOAD replace(F, '"', '') as F;
LOAD replace(F, ': "', ':"') as F;
LOAD [@1:n] as F FROM Source.txt (fix, codepage is 1252);
Also helpful could be to count the number of the delimiter chars and to read their position respectively to find any other definite/unique values within your string/fields to be able to apply mid/left/right-functions to adjust the content.
- Marcus
I'm not really sure if I understand your issue. If a txt-file isn't loaded completely the cause is often the msq-statement within the fileformat or an EOF char which could be handled with no EOF.
But because of your specified space as delimiter I assume that at least @6 contains some spaces within it and/or also some quotes. If this is the case the fileformat couldn't be defined appropriate and you need some additionally steps to clean your data - maybe by pre-loading the file with a fix length, like:
LOAD [@1:n] FROM Source.txt (fix, codepage is 1252);
and there counting/replacing your delimiter/quotes chars so that you could apply a "classical" fileformat-statement again.
- Marcus
Depending on the varity of your real data it could be quite hard to handle all possibilities but with a multiple step approach in a preceeding-chain most of them should be solvable. This means something like this:
// LOAD replace(F, ' ', '|') as F;
LOAD replace(F, '"', '') as F;
LOAD replace(F, ': "', ':"') as F;
LOAD [@1:n] as F FROM Source.txt (fix, codepage is 1252);
Also helpful could be to count the number of the delimiter chars and to read their position respectively to find any other definite/unique values within your string/fields to be able to apply mid/left/right-functions to adjust the content.
- Marcus
This won't work because the fileformat is used at first and therefore the afterwards following replacement-statements run against the wrong data. This means you need at first to clean the data before you could load them into your target-table.
Take a look on my preceeding-example from above and develop it step by step.
- Marcus
Without a valid delimiter and valid quotes you don't have a valid data-structure within your files and there is no possibility to load the data "column per column" - at least not in Qlik from a txt (I doubt that other tools provide more options). If you could influence the datastructure in any way maybe in regard to the output-format so that it comes as xlsx, xml or as a sql-db it would be probably simplify your task.
Nevertheless I think my suggestion should work and I don't see much what could violate your customer ristrictions. Yes its loading at first everything into a singe field, adjusting the various issues and afterward you could load from this field with from_field or you stores the table as txt again and load the data from there.
- Marcus
Hi, I tried your solution I read the whole line in a table, I replaced the characters "with the blank and then I reread the line from the table but how can I tell it that there are 8 fields separated by shift now? My idea was to save the monocolumn table in a file and reread it but how do I in that case tell him that there are 8 columns to save with the shift in the middle?