Dec 27 2022 09:51 AM - edited Dec 27 2022 09:52 AM
I have files of raw testing data in .txt form that I need to import into Excel spreadsheets.
The .txt files are formatted as follows:
X47312804237ACDBBADCADBCDBDCCBDAACCDACBA
(The letter plus number on the left indicates student code, and the subsequent letter (ABC or D) indicates option selected on a test).
Is there a way to convert this to Excel so that each answer (ABC or D) gets its own column? I'm struggling to find a solution. Thanks!
Dec 27 2022 10:02 AM
Dec 27 2022 10:26 AM
=DROP(TRANSPOSE(BYROW( SEQUENCE(LEN(A1)), LAMBDA(x, MID(A1, x, 1) ) )),,12)
You can try this formula if you work with Office365.
Dec 27 2022 10:30 AM - edited Dec 27 2022 11:44 PM
If you run Excel >/= 2016 on Windows that sounds doable with Get & Tranform aka Power Query:
Dec 27 2022 03:29 PM
Dec 27 2022 04:13 PM - edited Dec 27 2022 04:14 PM
Assuming that all the numbers will always be in a sequence to the left and there are no stray numbers within the multiple choice area -
I am also assuming that your .txt converts each student to a single cell of data (e.g. A1), then this should do the trick (though Quadruple_Pawn's response is much better if you have Lambda):
=LET(DATA,A1,
SPREAD,MID(DATA,SEQUENCE(LEN(DATA)),1),
NTHPOS,IFERROR(MATCH(1E+100,INDEX(--SPREAD,)),0),
TRANSPOSE(INDEX(SPREAD,SEQUENCE(LEN(DATA)-NTHPOS,1,NTHPOS+1,1))))
Dec 27 2022 04:21 PM
Dec 27 2022 11:50 PM - edited Dec 28 2022 01:23 AM
Forgot to attach the Power Query option yesterday (apologies) - post edited
Another 365 option:
in C1:
=LET(
SplitStudAnsw, LAMBDA(string,array,
LET(
x, MIN(SEARCH(array,string,2))-1,
answers, MID(string,x+1,LEN(string)-x),
HSTACK(LEFT(string,x), MID(answers,SEQUENCE(,LEN(answers)),1))
)
),
Answers, CHAR(SEQUENCE(4,,97)),
SplitEach, REDUCE("",Strings,
LAMBDA(seed,str, VSTACK(seed,SplitStudAnsw(str,Answers)))
),
VSTACK(
HSTACK("Student", "A" & SEQUENCE(,COLUMNS(SplitEach)-1)),
IFNA(DROP(SplitEach,1),"")
)
)