Dynamic data import / export

datenbank

simply more productive
Up to 10,000 records can be processed with the freeware version!

Convert a Windows ANSI flat file to an MS DOS ASCII CSV file

With this example we wish to demonstrate how easy it is to convert text files to other formats (codepages and locales) with the TextFile Adapter and at the same time perform dynamic calculations.

Convert Windows ANSI to MS-DOS ASCII
Convert Windows ANSI to MS-DOS ASCII

With this example we wish to demonstrate how easy it is to convert text files to other formats (codepages and locales) with the TextFile Adapter and at the same time perform dynamic calculations. You can open the example directly in FlowHeater using the menu option "Examples->TextFile Adapter->Windows ANSI FlatFile to ASCII". You can see it done the other way around (ANSI to ASCII) here.

Note: The same procedure is used to convert to UNICODE (utf7, utf8, ...), EBCDIC, etc.

Task

We have a Windows ANSI flat file and for a supplier in the States (USA) we want to prepare an MS DOS ASCII CSV text file. The date format is to be in the American form of m.d.yyyy (i.e. month.day.year). The supplier wants numbers in the following format: $1,000.23 and that means the decimal character is a point, the thousand-separator a comma and the currency symbol a dollar sign. The character set for our file will additionally be converted from ANSI Codepage 1252 to MS DOS Codepage 437.

 

What we have to do

Open the FlowHeater Designer and save a new Definition file using the menu option "File->New". Select in the dropdowns the TextFile Adapter on both sides.

 

On the READ (left) side

  1. open the Configurator for the READ Adapter (left) side
  2. for the filename enter "ansi-flatfile.txt"
  3. check the checkbox "First row contains field names" and reply to the query as to whether the field names should be loaded from the file with "no"
  4. ensure that the codepage "1252, Windows-1252,Westeuropäisch (Windows)" is selected
  5. select under the delimitation radio options "fixed widths"
  6. click in the lower area with the mouse on the sliders in order to adjust the sliders to match the field divisions visually. Alternatively, you can manually specify the field widths/lengths by switching to the "Fields / Data types" tab
  7. switch to the "Fields / Data types" tab and assign some suitable names to the fields

That is all for this side.

 

On the WRITE (right) side

  1. open the Configurator for the WRITE (right) side
  2. for the filename enter something like "output.txt", for example
  3. check the checkbox "First row contains field names"
  4. choose for codepage "437, IBM 437,OEM United States"
  5. switch to the "Separators" tab and choose as the CSV separator string "abc"
  6. switch to the "Fields / Data types" tab and insert the following fields, including the specified FlowHeater data types

    ID (INT)
    Description-1 (String)
    Description-2 (String)
    Date (Date)
    Price (Currency)

That is all for this side.

 

Finishing up

Now all we need is to connect the individual fields together and introduce a handful of Heaters in between. How to do this is described in the Hello World (1, 2, 3) examples, or simply inspect the completed Definition provided in the FlowHeater examples directory.