안녕하세요,
텍스트 파일에서 필요한 데이터를 추출하는 데 많은 어려움을 겪고 있습니다. 데이터는 아래 형식의 .txt 파일 (첨부 된 파일)이며 큰 (100MB) 파일로 반복됩니다.
온도 0x100
PART ID 0x5A6A111F
5626 0 PASS DC_VoLevels.4 GPIO_32 312 1.0000 V 3.1638 V 3.3000 V -4.0000 mA 0
사이트 정렬 큰 상자
------------------------------------
0 123 4
나는 2 열과 표제 Part ID와 Bin을 가진 dat 테이블과 아래 나열된 데이터를 생성해야한다.
PART ID Bin
0x5A6A111F 4
부품 ID를 가져올 수는 있지만 아래의 Bin 및 번호는 문제가 있습니다. 어떤 도움이라도 대단히 감사하겠습니다.
젠
이와 같은 데이터를 가져 오는 것은 까다 롭지 만 파일을 한 줄씩 읽고 키워드를 확인하여 데이터로 수행 할 작업을 결정할 수 있습니다. 자세한 내용은 아래 예제를 참조하십시오.
// load the file to be imported as a string
str = Load Text File( "$downloads\SampleFile.jsl" );
// create a table to add to
nt = New Table( "Example",
New Column( "PartID", "Character" ),
New Column( "Bin", "Numeric" )
);
// create a list with strings of each line of data
lines = Words( str, "\!N" );
// loop through each line of the file
for(i=1,i<=nitems(lines),i++,
if( // If the line starts with PART ID,
starts with(lines[i], "PART ID" ),
// it's the start of a new row
nt << add rows(1);
// grab the PartID at the end of the line
nt:PartID = Word( -1, lines[i] );
,
// if it starts with a bunch of dashes
starts with(lines[i], "---" ),
// the next line must contain column values
// so grab them and split them by spaces
colVals = Words( lines[i+1], " " );
// set the Bin column to the value in the third position
nt:Bin = colVals[3];
);
)
이 스크립트는 다음 테이블을 작성합니다.
