Prepend Filename to each row in tab separated file

0

Been looking around the forums but still having a hard time with the below need:

I have a large tab separated text file that I need to add a column to with the file's name (or any constant value basically) to then use in a data warehouse project. I'm using windows and cannot install applications as its a company machine, but I can use powershell/cmd. I'd prefer not to have to echo through each line as the file has around 1.8 million lines. Any ideas?

Logic: I'm using Tableau as my data tool and importing a text file each week that has weekly data. The issue is that there is no field in the text file to indicate which week it is (other than the text file's name), so when I do a UNION of multiple files I lose track of which data is for which week. I'd ideally have a a way to add either the filename (which has the date in it) or a 'Wk 01 2017' sort of thing.

Thanks!

Elliott Bowles

Posted 2017-01-12T16:14:14.030

Reputation: 121

I'm using Tableau but have to add a data file each week via a union to the previous week data sources. My issue is each data file has a week's worth of data but there is no column signalling which week the data is for, hence the need to add the filename or other fixed-value I'm sure there may be an easier way, thanks for your help! – Elliott Bowles – 2017-01-12T16:24:08.027

Answers

0

Looks like I solved it - Tableau actually creates a 'table name' field when you do a union of multiple files, so there was no need to manipulate the files directly.

Elliott Bowles

Posted 2017-01-12T16:14:14.030

Reputation: 121