Question

Non-consistant text to json

  • 4 November 2019
  • 1 reply
  • 0 views

Hello, came across Safe Software while researching options to convert text files into json. Some of the files I have are non-consistant. That is, beyond the date/time, each entry can vary from one line to n number of lines before the next entry. Only constant is the first line of each entry has date/time in this format:

2019-06-05 07:31:49.968

There may be more data after the date/time on the same line. A delimiter is used to separate data fields, however, there are cases in which the delimiter is not written to the file after a line return. In this case the next line starts with no delimiter so the first field could be wrongly seen as belonging to the previous.

Anyhow, any one have experience with converting text files like this using any of the Safe Software tools?

1 reply

Userlevel 4
Badge +13

Read_Text.fmwtHi @vanawful This template workspace uses a StringSearcher and an AttributeValidator to test for the date, assigns the group of features by the following set of characters until the next comma, and uses a VariableSetter and VariableRetriever to set that to the following text lines until one starts with a valid date, creating a new group.

Reply