Extract Address information from large text file

cmical

New Member
Joined
Dec 7, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
I've really been struggling with this one. I am not well versed in VBA as a forewarning.

I have a large text file containing data that I've scanned in from paper and have used OCR to create said text file. This file contains records of customer information. I need to extract only the address lines of the records. For example, the record contains 12-15 lines of information above the address lines, and another 12-15 lines before the next record starts. Each line that I want to extract (3) contain the following: 'Name(s):' 'Address:' and 'City/State/Zip:' before the actual data that I want to get at.

I'd like to import the text into column A, and then "process" that data into three separate columns: "Name" and "Address" and "City/State/Zip". I cannot figure out how to do this at all.

Any suggestions?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You could use power query for this.
Load the csv file into power query.
Promote headers
Filter lines - Filter-> Text Filter, Begins with (use Name:, Address: and City/State/Zip: ) - This will leave you with just the lines you care about.
Split column by delimiter using ":" - You'll have two columns of data, one that is the variable name (i.e. name, address etc) and one that is the value.
Pivot the table.
 
Upvote 0
There is no CSV file for the data. It's a large text file that I plan on copy/pasting into a column in Excel.

With Power Query still work?
 
Upvote 0
Yes, you can load the file into power query directly, or you can paste the data into excel, then load it into power query as a table. The first one is more efficent and will let you pull in files larger than 1.4 million rows which is the max you can have in excel. I added some youtube videos to help you out..

Load the text file into power query.
Promote headers
Filter lines - Filter-> Text Filter, Begins with (use Name:, Address: and City/State/Zip: ) - This will leave you with just the lines you care about.
Split column by delimiter using ":" - You'll have two columns of data, one that is the variable name (i.e. name, address etc) and one that is the value.
Pivot the table - I'll let you google this one.
 
Upvote 0
Yes, you can load the file into power query directly, or you can paste the data into excel, then load it into power query as a table. The first one is more efficent and will let you pull in files larger than 1.4 million rows which is the max you can have in excel. I added some youtube videos to help you out..

Load the text file into power query.
Promote headers
Filter lines - Filter-> Text Filter, Begins with (use Name:, Address: and City/State/Zip: ) - This will leave you with just the lines you care about.
Split column by delimiter using ":" - You'll have two columns of data, one that is the variable name (i.e. name, address etc) and one that is the value.
Pivot the table - I'll let you google this one.

Hayden - you rock. I'm a visual dude and the videos will help me through this. I'll update this post when successful. Thank you.
 
Upvote 0
You may need to add a step before pivoting the table. Something like a record number column. It would include three rows of 1, then three rows of 2, then 3 rows of 3 etc. I don't use pivot much, and I can't remember if you need that or not. You can use the add column from example, and I bet it would create that for you easily.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,150
Members
453,021
Latest member
Justyna P

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