I want to be able to map the atribute names from the header csv to the incoming CSV's with the data in?
I suspect there is a simple way of doing it but i can't find one.
Any help will be appreciated.
I want to be able to map the atribute names from the header csv to the incoming CSV's with the data in?
I suspect there is a simple way of doing it but i can't find one.
Any help will be appreciated.
Add the columnnumber from the csv with the values to the header-csv. (if they are in the same order then its less effort)
Use this as a schemamap.
Use a exposer with the same haeder-csv as source.
Copy attribute from exposer to writer.
lots of ways to do this. Here are a couple, both assuming that the format of the CSV is constant
read the files as txt files. Expose the format attribute row_number and.
Make header file 1st row number.
Renumber the row-number attribute from headers by row_number = row_number +1
Send both files to a sorter, ascending. And output as single file.
I have the same requirement and have been trying to implement some of the suggestions above.
My data has 77 fields so I've been trying to load in the headings from a CSV rather than having to re-type them. I've created 2 field map CSVs, both containing the old and new field names. One has them in rows and the other in columns.
I've tried the Import button on the AttributeManager but it either doesn't do anything (field names are not renamed) or it hangs on "Reading Dataset" after I select the CSV with the field map in. Has anyone used the Import button?
I've also tried the SchemaMapper but this has not been successful either. I've used my field map CSV where there is a column containing the old field names (col0, col1, etc) and a column containing the new field names. The SchemaMapper action is Map Attributes. However when I inspect the output, the attributes are still called col0, col1, col2, etc with a _schemamapperid column at the end. Am I doing something wrong here?
Apart from using the AttributeManager and manually typing the field names in, the only thing I have got to work so far is to read the header file first then the data, then send both to the same Writer to write a new CSV and un-tick Output Field Names on First Line. However this has the disadvantage of having to write a CSV before you can do any more processing.
I have the same requirement and have been trying to implement some of the suggestions above.
My data has 77 fields so I've been trying to load in the headings from a CSV rather than having to re-type them. I've created 2 field map CSVs, both containing the old and new field names. One has them in rows and the other in columns.
I've tried the Import button on the AttributeManager but it either doesn't do anything (field names are not renamed) or it hangs on "Reading Dataset" after I select the CSV with the field map in. Has anyone used the Import button?
I've also tried the SchemaMapper but this has not been successful either. I've used my field map CSV where there is a column containing the old field names (col0, col1, etc) and a column containing the new field names. The SchemaMapper action is Map Attributes. However when I inspect the output, the attributes are still called col0, col1, col2, etc with a _schemamapperid column at the end. Am I doing something wrong here?
Apart from using the AttributeManager and manually typing the field names in, the only thing I have got to work so far is to read the header file first then the data, then send both to the same Writer to write a new CSV and un-tick Output Field Names on First Line. However this has the disadvantage of having to write a CSV before you can do any more processing.
I had the same question, which is why I got to this page, and @david_r's second bullet point in the comments gave me the answer. Actually, you don't even need to do a concatenate of your header file and one of your data files:
(Note: I realise that the original post is almost 3 years old, so it may well be that this functionality was not yet available in 2015)
I had the same question, which is why I got to this page, and @david_r's second bullet point in the comments gave me the answer. Actually, you don't even need to do a concatenate of your header file and one of your data files:
(Note: I realise that the original post is almost 3 years old, so it may well be that this functionality was not yet available in 2015)
@arnold_bijlsma THANK YOU for this very helpful step by step!!! This was a life saver for me!
Since more time has past and I'm working in FME 2019.2 it looks like some things have changed. I'll go ahead and post the modified steps I used for the next poor soul.
Here's what I found to work:
Now that the reader has been added to your workspace:
1. Right click the new reader in the left Navigation pane and select "Edit 'xxxx' Parameters" to change its properties.
2. In the Edit window, change the following parameters:
THANK YOU AGAIN FOR YOUR HELP!
@arnold_bijlsma THANK YOU for this very helpful step by step!!! This was a life saver for me!
Since more time has past and I'm working in FME 2019.2 it looks like some things have changed. I'll go ahead and post the modified steps I used for the next poor soul.
Here's what I found to work:
Now that the reader has been added to your workspace:
1. Right click the new reader in the left Navigation pane and select "Edit 'xxxx' Parameters" to change its properties.
2. In the Edit window, change the following parameters:
THANK YOU AGAIN FOR YOUR HELP!
Adding a comment on another use case/workflow when working with CSV files that do not have headers.
A project required mapping FCC antenna data, however the FCC data was broken out into dozens of tables. Due to the number of distinct tables involved I found that the above steps were a bit too tedious. I found it useful to take a few steps to prepare the data prior to being read into FME:
This eliminated a step when setting up the CSV reader in FME.
If anyone is interested in FCC antennae data, it took a bit of leg work to find the information on the FCC website so if anyone has interest, here are some links:
NOTE: FCC databases are downloaded as tables in .DAT files, these are a pipe deliminated file format which FME reads as a "Aircom ENTERPRISE Map Data/ASSET Data" format by default; however this results in an error, the CSV format needs to be manually selected.