Skip to main content Skip to complementary content

Extracting and transforming data in CSV format

Procedure

  1. From the Palette, drag and drop a cSetHeader, cCsvParser, cCsvWriter, two cFile and cLog components onto the design workspace.
  2. In the Basic settings view of the first cFile component, browse to or enter the input file path in the Path field, and leave the other parameters as they are.
    In this scenario, a CSV file sample_data.csv with the following content is in the specified directory:
    ID,Name,Age,City
    # Comment line
    1,Alice,28,New York
  3. In the Basic settings view of the cSetHeader component, click [+] in the Headers to remove area to add a row in the Headers table, and enter "*", "CamelFileName" in the Name field to remove all headers except CamelFileName.
  4. In the Basic settings view of the cCsvParser component, select Custom in the CSV Format list and keep the default settings of the other options.
  5. In the Basic settings view of the first cLog component, select the Format the log output option and add arguments "multiline" and "showHeaders" with the value true.
    Repeat this step to configure the second cLog component with the same settings.
  6. In the Basic settings view of the cCsvWriter component, select Excel in the CSV Format list.
  7. In the Basic settings view of the second cFile component, browse to or enter the output file path in the Path field, and leave the other parameters as they are.
  8. Click the Code tab at the bottom of the design workspace to have a look at the generated code.
  9. Click the Run view to display it and click the Run button to launch the execution of your route. You can also press F6 to execute it.
    RESULT: The log messages are printed in the console. The data from the input CSV file is written in Excel format.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!