Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Vasiliy_Beshentsev
Creator III
Creator III

Load file with delimiters?

Hello everyone!

I Need to load file with delimiter comma (',')  until  i get word "Context=" and then i need to get all after "Context=..." into last field?

How to do that?

7 Replies
marcus_sommer

I think some sample-records of this text-file would be useful.

- Marcus

Vasiliy_Beshentsev
Creator III
Creator III
Author

Here, please

marcus_sommer

The first record is quite different to the following records - this meant you might need several load-steps to the header and the records and to match them in any way. Here a suggestion how the following records could be loaded:

records:

LOAD subfield([@1:n], ':', 1) as F1, subfield([@1:n], ':', 2) as F2, subfield([@1:n], ':', 3) as F3

FROM [test.txt] (fix, codepage is 1252, header is 1 lines);

In a similar way (with subfield() and/or other string-functions) would it be possible to load also the first record.

- Marcus

Vasiliy_Beshentsev
Creator III
Creator III
Author

So now i need to update last field with Context=

How to add data to this field?

marcus_sommer

Based on your sample records - how should be the output-table look like?

- Marcus

Vasiliy_Beshentsev
Creator III
Creator III
Author

I need to get this, 2017-01-19 14_11_30.png

Last field must be "Context=words words words"

marcus_sommer

Regarding to your sample-data would be something like this possible:

Map_Extra:

mapping load filebasename() as FilebaseName, concat([@1:n], ' ') as Value

From [test.txt] (fix, codepage is 1252, header is 1 lines);

Data:

first 1 LOAD

     @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13,

     @14 & applymap('Map_Extra', filebasename(), '#NV') as @14

FROM [test.txt] (txt, codepage is 1252, no labels, delimiter is ',');

- Marcus