上QQ阅读APP看书,第一时间看更新
Working with flat files - Import option
In the previous section, we discussed the importing of relational tables. Before we start working on importing flat files, we will discuss some important aspects about Flat Files.
Flat files form a very important aspect of any ETL tool.
Flat files are of two types -- delimited and fixed width.
- In delimited files, the values are separated from each other by a delimiter. Any character or number can be used as the delimiter, but usually, for better interpretation, we use special characters as delimiters. In delimited files, the width of each field is not a mandatory option as each value gets separated by another using a delimiter. Refer to the following screenshot to understand a delimited file. The delimiter used in the file is the comma (,).
- In fixed width files, the width of each field is fixed. The values are separated from each other by the fixed size of the column defined. There can be issues in reading the data if the size of each column is not maintained properly. As shown in the following screenshot, in the fixed width file, the width of each field is fixed:
Take a look at the description of each field:
- EMPLOYEE_ID: 4 Bytes
- FIRST_NAME: 10 Bytes
- LAST_NAME: 10 Bytes
- AGE: 2 Bytes
- JAN_SAL: 4 Bytes
- FEB_SAL: 4 Bytes
- LOCATION: 10 Bytes
If the size of a particular value is not equal to the size mentioned, we need to pad the value with spaces.
We move on to working with both the types of Flat Files in the subsequent two subsections.