Link to home
Start Free TrialLog in
Avatar of ITGuy4life
ITGuy4lifeFlag for United States of America

asked on

Text Document Conversion into Excel - Row to Column

I have 1000's of records in a semi structured text file and need help importing the data into Excel.  The structure of the data is as follows;

First Name: Bob
Last Name: Smith
Branch: Finance Contractor

First Name: Jane
Last Name: Williams
Branch: Finance Employee

First Name: Mark
Last Name: Doe
Branch: Human Resources Employee

How do I go about importing this efficiently into Excel with 4 columns (First Name, Last Name, Branch, Emp Type).  I tried Googles OpenRefine but I haven't had any success.  

Some sample .net c# code is also appreciated.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A fastndirty way do to this is to use MS Word, and a bunch of Find / Replaces.  Copy your data to a blank Word doc.

Do these - skipping all " marks, of course

FIND "First Name: " - REPLACE WITH "" ie nothing
"^lLast Name: " - REPLACE WITH "," ie a comma
"^lBranch: " - REPLACE WITH ","
"^l^l" - REPLACE WITH "^p"

Explanation
The first one just deletes your unnecessary First Name: text.  Note, there's a space after the colon.
The second one does the same for Last Name: , but also removes the Line Break - indicated by the ^l (that's a lower case L) character, and inserts a comma in its place as a delimiter.
the third one does the same for Branch:
the fourth one replaces the double blank line that you have with a single Paragraph mark instead - the ^p symbol.

Sounds fiddly, but is pretty flexible in a hurry for simple tasks.
Word is better than Excel here as it has the additional formatting tools to remove your line breaks, etc.

For more info on what else Word can replace, check the More.. Special options in that dialog box.

copy the resulting list back to Excel, and use Text To Columns to split it up.
Avatar of ITGuy4life

ASKER

This worked perfectly!  I needed to tweak the script