Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
joegrant55
Contributor
Contributor

Store txt with header row

Hi

I have created a table that stores multiple fields into a txt file.

I need to add a 'header row' above the current fields as this txt file is loaded into a system that uses the header row as an indication of what to do with the file. My delimiter is '|'.

Example:

Header1|Header2|Header3|Header4

Field1|Field2|Field3|Field4|Field5|Field6|Field7|Field8|Field9|Field10

Does anyone know how I add a header row in the script?

Thanks,

Joe

Labels (5)
13 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

How are you storing this table in txt file?

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
joegrant55
Contributor
Contributor
Author

Like so:

TableExample:

LOAD

 FIELD1

 FIELD2

 FIELD3 etc.

From source

Store TableExample into TableExample.txt(txt);

 

 

 

joegrant55
Contributor
Contributor
Author

Apologies the store part is like so:

 

Store TableExample into TableExample.txt (txt, delimiter is '|');

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You should give delimiter like below and it should work.

 

Store [TableName] into [Path]\[FileName].Txt(txt, delimiter is '|');

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

When i performed the same thing, I could see the headers (Field Name) in the file.

Dont you see them?

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
joegrant55
Contributor
Contributor
Author

Hi

Yes I see them but as per my example I need another row above the field name headers made up of different names.

Header1|Header2|Header3|Header4

FieldName1|FieldName2|FieldName3|FieldName4|FieldName5|FieldName6|FieldName7

I have attached a txt document example also.

Thanks,

Joe

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

What is the source of the table?

Is it Excel or database table?

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
joegrant55
Contributor
Contributor
Author

It has been created using multiple qvds and xlsx and then stored as a csv.

This csv. is then loaded, edited and saved as a txt file.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

You can do one thing.

Store that data in a temporary text file, similar to what you are doing currently.

Store [TableName] into [Path]\[FileName].Txt(txt, delimiter is '|');

Now write the load script to load this txt file (Newly created one in above step).

Your load statement should look like below.

Data:
LOAD @1 as Header1,
@2 as Header2,
@3 as Header3,
@4 as Header4

FROM
Path\Filename
(txt, codepage is 1252, no labels, delimiter is '|', msq);

And store this using normal Store command.

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!