Skip to main content
Solved

Append filename field to .csv bulk import Reader


gcarmich
Participant
Forum|alt.badge.img+1

I have 15 .csv files with different names but the same fields and a total of 1406 records. They are in the same directory. I want to merge all 15 files together and append the source file name to each record. I've tried FilenamePartExtractor, FilePathExtractor, and FeatureReader but haven't been able to to get the desired result. I usually get back more records than I put in. Is there a straight forward method to append file name to each record?

Best answer by david_r

I'm not sure what the FilePathExtractor does, but based on the description on FME Hub I'm doubting it's what you want.

The easiest is probably to expose the feature attribute "fme_basename" on the reader and then rename it as required before writing. This attribute will contain the source CSV filename minus the file extension.

image

View original
Did this help you find an answer to your question?

2 replies

david_r
Celebrity
  • Best Answer
  • February 6, 2023

I'm not sure what the FilePathExtractor does, but based on the description on FME Hub I'm doubting it's what you want.

The easiest is probably to expose the feature attribute "fme_basename" on the reader and then rename it as required before writing. This attribute will contain the source CSV filename minus the file extension.

image


gcarmich
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • February 6, 2023

Wow! That was simple. I wasn't familiar with the term "basename". I was looking for filename or windows parameters


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings