This repo demonstrates how to import delimited files without headers in Flatfile.
- Import any pipe-delimited (.txt or .csv) file
- Automatically assign headers based on predefined mapping
- Process AMS-formatted data
- Upload any pipe-delimited file
- The system checks to see if the file has headers or not
- If not, the system will use the predefined headers
- The system automatically assigns headers based on column position
- Data is mapped to the appropriate fields in the sheet
- Process or transform the data as needed
- Clone this repository
- Install dependencies:
npm install - Create a
.envfile with your Flatfile credentials:FLATFILE_API_KEY=your_api_key FLATFILE_ENVIRONMENT_ID=your_environment_id - Start the development server:
npm run dev
The key components of this demo are:
- Delimiter Extractor: Configured to work with any .txt or .csv file
- Explicit Headers: Predefined headers are assigned to columns based on position
- AMS Sheet: Sheet configured to handle AMS data format
The main logic for header assignment is in app/extractors/delimiter/index.ts and the header definitions are in app/config/headers.ts.
You can test with any pipe-delimited file. The system will automatically assign headers based on the predefined mapping.
There's a "AMS" file in the sample-data folder that can be used for the AMS sheet. This file is a pipe-delimited .txt file with no headers.
To adapt this for your own use case:
- Modify the headers in
app/config/headers.ts - Update the sheet definition in
app/blueprints/sheets/ams.ts - Adjust the delimiter in
app/extractors/delimiter/index.tsif needed