Frage

I need to read the following text in a file and store the values with field names. Its actually copied from am excel sheet:

A: B C D E (not TEXT based)

Field Description Length in bytes Count Total bytes

Identification 10 1 10

IX 4 1 4

Scan date time 8 1 8

Machine type 4 1 4

I stored it in a stringlist and I am unsure about what to do next. Can anyone please help? Thanks.

War es hilfreich?

Lösung

First of all, I'd save it from Excel as a .csv, open it in Notepad, and copy it from there. The lack of (unambiguous) field delimiters in your current format makes it awkward to tokenise. When saving the .csv, pick a field delimiter which doesn't appear in any of your text fields, and leave the text delimiter blank.

With that done, just split each of your strings on the delimiter character, and do what you want with the pieces. Simplest way to do it is probably to set the string as the CommaText on a second TStringList.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top