This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I have daily data come in and need to make one of the columns the filename. i.e. reach record in the table would have "todaysfile_02162015.txt" or whatever the file name is. I can use "Field Info" to get the filename but then I can't link it back into the data so that every record has the filename. Note: it's the same filename for all the records.
If you choose "Full Path" (see below), this will give you the entire path. You can then use reg ex tools/formulas to strip out just the file name. I like to use the Text to Columns tool delimited on the "\". That way I just use a select tool after to take only the file name field. Saves from having to figure out the reg ex expression.
This is a great solution when the input is a flat file. What if the input is a database file? I don't see the "Output File Name as Field" when reading a database file!
I'm using ODBC connection to read a table that is sitting in MySQL and would like to have the database name as a new field. The database name is the date that the file was crated, and I would like to add it to every row. Exaclty the same problem as David's, but with database file.
Oh - yes, that's correct - the file name output option will not apply to ODBCs.
In this case, create an extra stream coming from your input that connect to the Field Info tool. Then use a select tool after that and choose only the "Source" field. That will have your database name. It might look ugly, so you may have to parse it out using Reg Ex or something like that.
Once you have that, you can just use an append tool to append that field to your entire dataset as an extra column.