レガシー システムをサポートする際に、次の形式でデータを格納するフィールド データ コレクターに直面しています。
# This is a comment <-beacuse it starts at the begining of the file
# This is a comment <- see above
# 1. Item one <- not a comment because it starts with 1.
# Description of Item 1 <- not a comment as it is after a line that starts with a number
data point 1
data point 2
data point etc
3 <-- represents number of data points under Item one
# 2. Item two <-- not a comment
# Description of item 2 <-- not a comment
data point 1
data point ..
data point 100
100
#3. Item three <--- not a comment
# Item three description
0
そのファイルを解析して各アイテムを独自のリストとして含める正しい方法はわかりません。常にではありませんが、データによって 2 つの異なるアイテムの間にランダムなスペースが追加される場合があることに注意してください。
そのようなファイルを解析する正しい方法は何ですか?