Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Add Header and Footer to TXT file

mrome
5 - Atom

Hi, 

 

I have a csv file that I am converting and saving as flat(txt) file and I have been asked to add a header and footer to it. 

The header and footers are not column names, but rather different information that needs to be added. 

What's the best way to go about solving this? How can I ensure I am adding in the first and last rows of the txt file? 

thanks in advance for any help. 

7 REPLIES 7
CharlieS
17 - Castor
17 - Castor

Hi @mrome 


Could you help me understand the ask? When you say "adding a header and footer" do you mean if this is printed (or otherwise taken to a paged format), that this information should repeat in their respective positions on every page? or just that you have rows of text and you want to add rows at the beginning/end to this body of text?

Paged:

I believe.txt files don't have the designations for header, footer, margins, pagation, or any formatting by design. This formatting is added upon the printing process by whatever program is used to do so. So the only option I see here would be to test the page/printing process to see the rows of text on each pages and add in the header/footer rows of text as appropriate. 

 

Rows at beginning and end:

I think the easiest way is to taken your rows of text, add RecordID values, then use those min/max values to assign values beyond (negative before, and greater than max after), so you can union and resort the rows. 

 

If this doesn't make sense, let's keep this conversation going and see what the Community comes up with!

Qiu
21 - Polaris
21 - Polaris

@mrome 
If we will just do the most straightforward way.

0105-mrome-A.PNGCapture1v.PNG

mrome
5 - Atom

Thank you both for your help. 

While I understand what you are saying I should do, the current issue I am facing is that I have been giving specific positions for each item in the header and trailer. These are different from those in the main data. I have attached a dummy sample as reference.

When I try to do it as it is now, the positions are switched around and it no longer works as requested. 

You will note in the select tool the positions for each column. 

Is it possible to do this right in Alteryx? 

thank so much in advance for your help. 

Luke_C
17 - Castor

Hi @mrome 

 

Please export your workflow as a yxzp file so the sample data is included (Options>Export Workflow)

mrome
5 - Atom

apologies--first time doing this. Please see below

Luke_C
17 - Castor

Hi @mrome 

 

By positions, I assume you're referring to the number of characters and not column ordering. Have you tried keeping your header/footer in one cell/field to control the positions more precisely? Can you mock up what the acceptable text file would look like? 

mrome
5 - Atom

I was able to solve the problem by doing the following: 

Formatted and saved the header and trailer files both as txt

formatted and saved the main data file as txt

Used Union to put them all together. This respects the format for each of them, without jeopardizing the others. 

 

Labels