Go Back
Custom Output via Imports
Publisher
:
Run In Lingk
Description
This recipe shows a scenario where you need to create a custom format out that differs from a traditional single row output, use the recipe 'Import' section to create custom output formats.
Browse the knowledge base
Twitter
E-Mail
# _____ _ _____ __ # | __ \ (_) |_ _| / _| # | |__) |___ ___ _ _ __ ___ | | _ __ | |_ ___ # | _ // _ \/ __| | '_ \ / _ \ | | | '_ \| _/ _ \ # | | \ \ __/ (__| | |_) | __/ _| |_| | | | || (_) | # |_| \_\___|\___|_| .__/ \___| |_____|_| |_|_| \___/ # | | # |_| # Project Name - Custom Output via Imports # Recipe URL - https://app.lingk.io/a/10932/tf/18661 # Description - This recipe shows a scenario where you need to create a custom format out that differs from a traditional single row output, use the recipe 'Import' section to create custom output formats. # Systems - # Connectors - LocalFile # Data Flows - Single Direction # Connection Type - LocalFile # Add Recipe notes / Change log information here! # _____ _ # / ____| | | # | | ___ _ __ _ __ ___ ___| |_ ___ _ __ ___ # | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __| # | |___| (_) | | | | | | | __/ (__| || (_) | | \__ \ # \_____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/ # # CONNECTORS specify what data will be pulled into the in-memory database during processing connectors: # Configure LocalFile connector in your Environment before running this recipe # LocalFile Setup - https://help.lingk.io/en/articles/126-local-file-connector-reference #### Start - Read sample file #### # The localFileReader gets the file that needs to be processed - name: sampleFile type: localFileReader format: excelFormat properties: fileName: "mySecondSpreadsheet.xlsx" #### End - Read sample file #### #### Start - Write sample file #### # The localFileWriter will contain the file with the customizations imported # 'fixedHeaderRef' has the header value from import section # 'fixedFooterRef' has the footer value from import section - name: convertedFile type: localFileWriter format: csvFormat fixedHeaderRef: header fixedFooterRef: footer properties: fileName: "rowsWithFixedContent.csv" #### End - Write sample file #### # ______ _ # | ____| | | # | |__ ___ _ __ _ __ ___ __ _| |_ ___ # | __/ _ \| '__| '_ ` _ \ / _` | __/ __| # | | | (_) | | | | | | | | (_| | |_\__ \ # |_| \___/|_| |_| |_| |_|\__,_|\__|___/ # Excel type is the format used in the file read readFormats: - name: excelFormat type: excel properties: worksheets: "data" useHeader: "true" # CSV type is the format used in the file writer as the final target writeFormats: - name: csvFormat type: delimited properties: quoteAllFields: true delimiter: ',' header: true # *********************************************************** I M P O R T S ********************************************************************** # Are needed to create a flat file that contains the custom format mapping that needs to be generated imports: # The following import represents the header of the file that will be created - name: header type: localFileImporter format: raw properties: fileName: "myNewFixedHeader.txt" # This import represents the footer of the file that will be created - name: footer type: localFileImporter format: raw # no need to specify a formatter for this properties: fileName: "myNewFixedFooter.txt" # _____ _ _ _ # / ____| | | | | | # | (___ | |_ __ _| |_ ___ _ __ ___ ___ _ __ | |_ ___ # \___ \| __/ _` | __/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| # ____) | || (_| | || __/ | | | | | __/ | | | |_\__ \ # |_____/ \__\__,_|\__\___|_| |_| |_|\___|_| |_|\__|___/ # STATEMENTS specify how the data should be processed while in memory statements: #******************************************************************** D I S C L A I M E R *********************************************************************************************** # * # Note that in an effort to keep recipes optimized for DPH (Data Processing Hours), print statements should be commented out after development has concluded for a recipe. * # For more information on DPH optimization, please visit the following help article - https://help.lingk.io/en/articles/212-minimizing-data-processing-hours-on-the-lingk-platform * # * #******************************************************************** D I S C L A I M E R *********************************************************************************************** - statement: (dataCount) => select count(*) from sampleFile #- statement: print dataCount # The convertedFile is the final file that already contains the header and footer previously imported # The sampleFile is the original file read and it is inserted into the convertedFile that is already the template - statement: INSERT sampleFile INTO convertedFile # Add more statements to convert, join, aggregrate, transform, and integrate your data
Build a recipe with multiple instances of the same connector
Graph QL Reader