0
저는 파이썬에 비교적 익숙하지 않아 분석하기 쉽도록 데이터를 파싱하는 데 도움이되는지 궁금합니다.지저분한 데이터 구문 분석
내 데이터 (각각 전체 라인) 다음과 같은 형태 :
20160930-07:06:54.481737|I|MTP_4|CL:BF K7-M7-N7 Restrict for maxAggressive: -4.237195
20160930-07:06:54.481738|I|MTP_4|CL:BF K7-M7-N7 BidPrice: -5.0 mktBestBid: -5.0 bidTheo: -4.096774 bidSeedEdge: 0.195028 bidUnseedEdge: CL:BF K7-M7-N7 = 0.14042 Min Bid: -6.0 Max Ticks Offset: 1 Max Aggressive Ticks: 1
이 내 코드는 지금까지
# Output file
output_filename = os.path.normpath("Mypath/testList.log")
# Overwrites the file
with open(output_filename, "w") as out_file:
out_file.write("")
# Open output file
with open(output_filename, "a") as out_file:
# Open input file in 'read' mode
with open("mypath/tradedata.log", "r") as in_file:
# Loop over each log line, Grabs lines with necessary data
for line in islice(in_file, 177004, 8349710):
out_file.write(line)
그것은 쉬운 그냥 통과하는 것입니다 와 같은 키워드로해라. bidUnseedEdge, mktBesdBid 등?
더 많은 컨텍스트가 필요합니다. 예를 들어 표현 유형을 변경하거나 요소를 찾고/필터링하는 것과 같은 몇 가지 이점을 얻기 위해 데이터 구문 분석이 수행됩니다. 파싱의 목표는 무엇입니까? 몇 가지 기준과 일치하는 줄 건너 뛰기? 표현을 바꾸시겠습니까? 그렇다면 어떤 유형으로? – sal
@Alex, 필요한 실제 출력물은 무엇입니까? – Prabhakar
나는 우리 제품 K7-M7-N7에 대한 데이터와 bidTheo 및 maxAggressive에 해당하는 값을 얻어 데이터를 분석 할 수 있도록 노력하고 있습니다. – Alex