+fixed
Define fixed Field Lengths when reading a TEXT or RECORD input File
Description
This command is meant only for TEXT or RECORD input files.
It has no relevance for CSV files.
The record may not only contain valid data, but also contain unused areas or padding that that should not be interpreted as data fields. They also have a width.
Unused areas must be marked with a colon (:). They will not be handed over as valid data fields, but omitted.
The sum of all widths (data and unused) must exactly give the record length (with one exception, see below).
In TEXT input files, this width does not include the line break that separates the data rows.
In RECORD input files, there is no separating line break between the data records, so this is the absolute length of each record, immediately followed by the next record with identical length.
More than one
Because there might be a huge number of columns in TEXT files, it is possible to give several consecutive
Only for TEXT input file:
If the last given field length is 0, this means that this column has a variable length, and extends to the next line break. Ths means, in this case this last field cannot contain any line breaks (the other fields can).
Pattern
+fixed=n1,n2,n3...
Usage Examples
- csvfox infile.txt +e=ASCII +fileype=TEXT +fixed=10,30,30,:2,5,20,35,4,:16 outfile.csv
- Reads infile.txt as a fixed-width ASCII-encoded text file, with one data record on each line.
Its first field has the width of 10 characters, then come two fields with a width of 30 characters each.
Then there is a gap of two characters whose content is to be ignored.
After this, follow some fields with a width of 5, 20, and 35 characters, and at last a field with a width of 4 characters.
At last, there are still exactly 16 characters at the end that will be ignored. This might be padding or might contain data that are not needed further.
All valid fields will be written in standard CSV format to outfile.csv in default encoding.