Skip to content

NikJ87/fffc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Fixed File Format converter

Your goal is to write a generic tool to convert fixed file format files to a csv file based on a metadata file describing its structure.

Feel free to use your favorite language and libraries if needed (but no proprietary libraries, only open source), fork this project and provide your complete code as a pull request (including source and tests).

Use case

Our fixed file format files can have any number of columns A column can be of 3 formats:

  • date (format yyyy-mm-dd)
  • numeric (decimal separator '.' ; no thousands separator ; can be negative)
  • string

The structure of the file is described in a metadata file in csv format with a line for each column defining:

  • column name
  • column length
  • column type

You should transform the file to a csv file (separator ',' and row separator CRLF)

The dates have to be reformatted to dd/mm/yyyy

The trailing spaces of string columns must be trimmed

The csv file must include a first line with the columns names

Example

Data file:

1970-01-01John           Smith           81.5
1975-01-31Jane           Doe             61.1
1988-11-28Bob            Big            102.4

Metadata file:

Birth date,10,date
First name,15,string
Last name,15,string
Weight,5,numeric

Output file:

Birth date,First name,Last name,Weight
01/01/1970,John,Smith,81.5
31/01/1975,Jane,Doe,61.1
28/11/1988,Bob,Big,102.4

Extra requirements

  • files are encoded in UTF-8 and may contain special characters
  • strings columns may contain separator characters like ',' and then the whole string needs to be escaped with " (double quotes). Only CR or LF are forbidden
  • in case the format of the file is not correct, the program should fail but say explicitly why
  • a fixed format file may be very big (several GB)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%