Add Header and Footer to TXT file
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
- Labels:
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@mrome
If we will just do the most straightforward way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @mrome
Please export your workflow as a yxzp file so the sample data is included (Options>Export Workflow)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
