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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Can you perhaps upload one of those ASCII files to somewhere (like OneDrive) and share a link with us so we can see what's inside? I expect Data, From Text/CSV should be able to pull this off.
 
Upvote 0
Upvote 0
Those are not public links - it requires everyone to request access to help.
 
Upvote 0
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.
 
Upvote 0
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.
Thank you so much for the work you’ve done.
The result is exactly what I need. But I’m going to have to hold my hands up and admit I’m lost as to how you achieved it.
I’ve had a quick go and I think there is fundamental gaps in my knowledge. So in the interest of not wasting your time…..
I’m going to go away and watch some you tube videos and try and bridge my knowledge gap before asking further questions and having you you explain what I imagine will be the equivalent of tying shoe laces.

Again thank you very much and I really want to understand this and be able to implement it myself.
Speak soon!!
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,180
Members
452,615
Latest member
bogeys2birdies

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