Converting a ASCII text file with strange delimiters.

Gazland

New Member
Joined
Feb 8, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,
Firstly.. Thanks to anyone that reads this and gives me help. I'm a total beginner when it comes to this and I'm not even too sure on how to ask this question properly. :biggrin:

OK....
I'm trying to create spreadsheets using data downloaded from an electrical testing device, Specifically a PAT Tester. The model I use for work does connect with software that you have to pay an extortionate amount of money for and I'm sure that software will present the data in a lovely way. However there is an option to download the data from it as an ACSII file. Which looks like this:

TEST NUMBER 0001
DATE 02-FEB-2024
TIME 12:07:35
TESTER 14N-1251
APP NO 231131
TEST MODE TEST
INS >19.99 Mohm P
USER admin
SITE Ravns Triangle
TEXT Heater
TEXT
TEXT
TEXT

TEST NUMBER 0002
DATE 02-FEB-2024
TIME 12:14:20
TESTER 14N-1251
APP NO 231132
TEST MODE TEST
INS >19.99 Mohm P
USER admin
SITE Ravns Triangle
TEXT Dehumidifier
TEXT
TEXT
TEXT

TEST NUMBER 0003
DATE 02-FEB-2024
TIME 12:16:16
TESTER 14N-1251
APP NO 231133
TEST MODE TEST
INS >19.99 Mohm P
USER admin
SITE Ravns Triangle
TEXT Radio Charger
TEXT
TEXT
TEXT

Ive tried to use carriage return as a delimiter to sort the information but that doesn't work I believe because its imported text and not create using alt-Return in excel.
Ive tried using notepad++ to replace all the carriage returns for commas and load that in but that just creates 1 row and a million columns.
The best Ive managed to do is make a file that's created from an unofficial device specific online converter, which looks great but some of the 'columns' and their data are missing. particularly the 'SITE' and 'USER' information. I tried to take a screen shot of what that site produced but the file size was too large to upload here. So Ive created a table below to show roughly what it should look like.
Test numberdatetesterapp noINSUSERSITEDescription
102 feb14N67523675<99.9meRavensthorpeRadio Charger
202 feb14N1543763<99.9meRavenshorpeKettle

I know from my experiments that there is more data in the file and the lines that say 'TEXT' are more than just that.

So lovely excel people how do I get these ASCII files off my machine and quickly make an excel spreadsheet from them?
I'm more than happy to upload one of the files for examination but I'm not sure you can on this site??

All Help much appreciated!!!
I'm an electrician and a live sound expert so if any one needs any help with those things let me Know!!
Gareth
 
Hi, one first approach:
Here the working file to download.
ExtractFromTxt.zip

You will have to paste in column A the content of your file

ExtractFromTxt.xlsx
ABC
1TextExist in listTest index
2 TEST NUMBER 0001TRUE1
3 DATE 02-FEB-2024TRUE1
4 TIME 12:07:35TRUE1
5 TESTER 14N-1251TRUE1
6 APP NO 231131TRUE1
7 TEST MODE TESTTRUE1
8 INS >19.99 Mohm PTRUE1
9 USER adminTRUE1
10 SITE Ravns TriangleTRUE1
11 TEXT HeaterTRUE1
12 TEXT TRUE1
13 TEXT TRUE1
14 TEXT TRUE1
15FALSE2
16 TEST NUMBER 0002TRUE2
17 DATE 02-FEB-2024TRUE2
18 TIME 12:14:20TRUE2
19 TESTER 14N-1251TRUE2
20 APP NO 231132TRUE2
21 TEST MODE TESTTRUE2
22 INS >19.99 Mohm PTRUE2
23 USER adminTRUE2
24 SITE Ravns TriangleTRUE2
25 TEXT DehumidifierTRUE2
26 TEXT TRUE2
27 TEXT TRUE2
28 TEXT TRUE2
29FALSE3
30 TEST NUMBER 0003TRUE3
31 DATE 02-FEB-2024TRUE3
32 TIME 12:16:16TRUE3
33 TESTER 14N-1251TRUE3
34 APP NO 231133TRUE3
35 TEST MODE TESTTRUE3
36 INS >19.99 Mohm PTRUE3
37 USER adminTRUE3
38 SITE Ravns TriangleTRUE3
39 TEXT Radio ChargerTRUE3
40 TEXT TRUE3
41 TEXT TRUE3
42 TEXT TRUE3
43FALSE4
44 TEST NUMBER 0004TRUE4
45 DATE 02-FEB-2024TRUE4
46 TIME 12:17:00TRUE4
47 TESTER 14N-1251TRUE4
48 APP NO 231134TRUE4
49 TEST MODE TESTTRUE4
50 INS >19.99 Mohm PTRUE4
51 USER adminTRUE4
52 SITE Ravns TriangleTRUE4
53 TEXT Radio ChargerTRUE4
54 TEXT TRUE4
55 TEXT TRUE4
56 TEXT TRUE4
57FALSE5
Sheet1
Cell Formulas
RangeFormula
B2:B57B2=SUM(IFERROR(SEARCH(Table2[Data types],A2),0))>0
C2:C57C2=IF(A2="",N(C1)+1,IF(N(C1)=0,1,C1))


Which is formated as a table.
Then you have the table where you define each data and formula in H2 shows you if new (not in the list) datatypes are present in the content of the text you pasted in column A. You will need to add them manually. For it to work correctly some strings in Table2 (datatypes), will have to have 2 spaces after the text. For example to differentiate "EARTH" from "EARTH CURRENT", the first actually has the text "EARTH " (with two spaces at the end). Thankfully the text in your sample file has a lot of spaces between the field name and the actual value of the field.



ExtractFromTxt.xlsx
EFGH
1OrderData typesNew data types
21 TEST NUMBERno new datatypes
32 DATE
43 TIME
54 TESTER
65 APP NO
76 TEST MODE
87 INS
98 USER
109 SITE
1111 IEC
1212 LEAD CONTINUITY
1313 EARTH CURRENT
1414 EARTH
1515 TEXT
Sheet1
Cell Formulas
RangeFormula
H2H2=IFERROR(FILTER(A2:A1000,(A2:A1000<>"")*(B2:B1000=FALSE)), "no new datatypes")


And the last formulas that filter the values and format them as table.

Cell Formulas
RangeFormula
K1:X1K1=TRANSPOSE(Table2[Data types])
J2:J21J2=LET(r, UNIQUE(Table3[Test index]), r)
K2:X8K2=IFERROR(TEXTJOIN(";",,TRIM(SUBSTITUTE(FILTER(Table3[[Text]:[Text]],(Table3[[Test index]:[Test index]]=$J2)*(ISNUMBER(SEARCH(K$1,Table3[[Text]:[Text]])))),K$1,""))),"")
Dynamic array formulas.


Here you will have to see if new columna appear (if new datatypes are added) and the number of rows may extend beyond 20, so you will have to copy down and right if necessary.
Hope this makes sense.
For sure this can be optimized and cleaned up, but it is what i could come up with for now.
Hi. Thanks again for you help.
This is all a bit beyond my understanding of excel. So apologies if my questions are fundamental.
I’ve tried to copy another similar file but with a larger number of tests in.
It loads in the extra tests in to the ‘new data types’ part (column J) and fills the final table up to 20. In column J it puts in the rest of the numbers (so in the case of this new file up to 81) but doesn’t fill in the rest of that table. I know you said I would need to copy down and right. What exactly do I copy and where do I copy it to to fill the rest of the table?

Cheers.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If you have more than 20 entries, you select the last row for example K21:X21 and copy it down till you have covered to the number of entries you have in your case 81. you can copy down further if you like, for example to row 200, if there is no data you just will get an empty string. So there will be no problem.
If you get new datatypes you will have to copy the last column lets say X2:X21 (or X2:X82) to the right.
The new datatypes that appear you should copy to the table in columns E and F. With the order column you can manually give it the sort the table as you like. Change the numbers and sort the from smallest to largest for example.
If something is unclear, let me know, or if you like you can share you txt file and I'll have a look.
 
Upvote 0
Hi Felix.
Thank you very much! That all makes sense now.
The file Works really well. You’re a legend.
 
Upvote 0
Hi again.
Here is a cleaner formula (dynamic array formula). That does the same. It adjusts the number of rows and columns depending on the input.
Here is the working sheet: ExtractFromTxt2.zip

here the XL2BB:

ExtractFromTxt2.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1TextOrderData typesNew data types
2 TEST NUMBER 00011 TEST NUMBERno new datatypes  TEST NUMBER DATE TIME TESTER APP NO TEST MODE INS USER SITE IEC LEAD CONTINUITY EARTH CURRENT EARTH TEXT
3 DATE 02-FEB-20242 DATE1000102-FEB-202412:07:3514N-1251231131TEST>19.99 Mohm PadminRavns TriangleHeater
4 TIME 12:07:353 TIME2000202-FEB-202412:14:2014N-1251231132TEST>19.99 Mohm PadminRavns TriangleDehumidifier
5 TESTER 14N-12514 TESTER3000302-FEB-202412:16:1614N-1251231133TEST>19.99 Mohm PadminRavns TriangleRadio Charger
6 APP NO 2311315 APP NO4000402-FEB-202412:17:0014N-1251231134TEST>19.99 Mohm PadminRavns TriangleRadio Charger
7 TEST MODE TEST6 TEST MODE5000502-FEB-202412:19:4214N-1251231135TEST>19.99 Mohm PadminRavns Triangle0.05 ohm PP13A 4way
8 INS >19.99 Mohm P7 INS 6000602-FEB-202412:23:1414N-1251231136TEST>19.99 Mohm PadminRavns TriangleHeater
9 USER admin8 USER7000702-FEB-202412:25:5314N-1251231137TEST>19.99 Mohm PadminRavns Triangle.2A0.1 ohm PHeater
10 SITE Ravns Triangle9 SITE8000802-FEB-202412:29:2214N-1251231138TEST>19.99 Mohm PadminRavns Triangle0.06 ohm PPIEC
11 TEXT Heater11 IEC 9000902-FEB-202412:31:0614N-1251231139TEST>19.99 Mohm PadminRavns Triangle.2A0.1 ohm PMonitor
12 TEXT 12 LEAD CONTINUITY10001002-FEB-202412:33:3614N-1251231140TEST>19.99 Mohm PadminRavns TriangleFan heater
13 TEXT 13 EARTH CURRENT11001102-FEB-202412:35:0614N-1251231141TEST>19.99 Mohm PadminRavns TriangleCharger
14 TEXT 14 EARTH 12001202-FEB-202412:39:5814N-1251231142TEST>19.99 Mohm PadminRavns Triangle0.05 ohm PPVertical Powe
1515 TEXT13001302-FEB-202412:52:3014N-1251231143TEST>19.99 Mohm PadminRavns Triangle.2A0.1 ohm PHeater
16 TEST NUMBER 000214001402-FEB-202412:56:5414N-1251231144TEST16.62 Mohm PadminRavns Triangle.2A0.1 ohm PHeater
17 DATE 02-FEB-202415001502-FEB-202412:59:5814N-1251231145TEST>19.99 Mohm PadminRavns TriangleCharger
18 TIME 12:14:2016001602-FEB-202413:02:5314N-1251231146TEST>19.99 Mohm PadminRavns Triangle.2A0.1 ohm PMonitor
19 TESTER 14N-125117001702-FEB-202413:05:3114N-1251231147TEST>19.99 Mohm PadminRavns TriangleDehumidifier
20 APP NO 23113218001802-FEB-202413:07:2014N-1251231148TEST>19.99 Mohm PadminRavns TriangleFan heater
21 TEST MODE TEST19001902-FEB-202413:09:3114N-1251231149TEST>19.99 Mohm PadminRavns Triangletv
22 INS >19.99 Mohm P20002002-FEB-202413:11:3614N-1251231150TEST>19.99 Mohm PadminRavns Triangle0.09 ohm PP4 Way
Sheet1 (2)
Cell Formulas
RangeFormula
F2F2=IFERROR(FILTER(A2:A1000,(A2:A1000<>"")*(#REF!=FALSE)), "no new datatypes")
H2:V22H2=LET(t, A2:A10000, maxrow, MAX(ROW(t)*(t<>"")) - ROW(InputText[[#Headers],[Text]]), d, TAKE(t, maxrow), i, DROP(REDUCE("", d, LAMBDA(ini,x, VSTACK(ini,N(TAKE(ini,-1))+(x="") ))),1)+1, h, TRANSPOSE(DataTypes[Data types]), r, UNIQUE(i), r_m, DROP(REDUCE("", h, LAMBDA(ini,x, HSTACK(ini, r))),,1), h_m, DROP(REDUCE("", r, LAMBDA(ini,x, VSTACK(ini, h))),1), res, MAP(r_m, h_m, LAMBDA(x,y, IFERROR( TRIM(SUBSTITUTE(CONCAT(FILTER(d, (i=x)*(ISNUMBER(SEARCH(y, d))))), y,"")), "") )), fres, HSTACK(VSTACK("", r), VSTACK(h, res)), fres )
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top