How do i convert my notepad file which is in Row format to a Excel of Column format

littleman2000

New Member
Joined
Feb 24, 2020
Messages
2
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi,
I want to convert a notepad file(.txt format) to a excel(.xlsx format)

The format which i have in my notepad(text file) as below,
[User]
uid={moderator removed}
last_name={moderator removed}
first_name=Gerald
email_address={moderator removed}
accessibility=0
SAPME:DEFAULT SITE=XX92
role=SAP_XMII_User;SAP_ME_USER;
[User]
uid={moderator removed}
last_name={moderator removed}
first_name=Rob
email_address={moderator removed}
accessibility=0
role=SAP_ME_USER;SAP_XMII_User;
[User]
uid={moderator removed}
last_name={moderator removed}
first_name=Arun
email_address={moderator reomved}
accessibility=0
role=SAP_XMII_User;SAP_ME_INTEGRATOR;SAP_XMII_DynamicQuery;SAP_XMII_Developer;
group=Administrators;


The format which i need to change to in Excel is as below,
1582620159072.png


I have tried by enabling a "Record Macro" and then by using a Delimiter and Transpose functionalities from the Excel
But i couldn't get the end result as Field Names are not common to a particular User Row-sets.

Thanks!
Shaan.
 
Last edited by a moderator:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi ShaanPrakash,

I'm sure the VBA experts will be here soon to give you a more elegant solution, but in the meanwhile here's a solution using functions which just needs a little manual intervention.

Paste your Notepad into column A, then go to the last data row and add another "[User]" just to simplify the formula finding the last range.

Copy the formulae in columns C to L down as many rows as the maximum number of [User]s

Cell Formulas
RangeFormula
C2:C7C2=IF(COUNTIF(A:A,"[User]")<ROW()-1,"",AGGREGATE(15,6,ROW(A:A)/(A:A="[User]"),ROW()-1))
D2:D7D2=IFERROR(ADDRESS(C2,1)&":"&ADDRESS(C3-1,1),"")
E2:E7E2=IFERROR(RIGHT(INDEX(INDIRECT($D2),MATCH(E$1&"*",INDIRECT($D2),0)),LEN(INDEX(INDIRECT($D2),MATCH(E$1&"*",INDIRECT($D2),0)))-LEN(E$1)),"")
F2:L7F2=IF($E2="","",IFERROR(RIGHT(INDEX(INDIRECT($D2),MATCH(F$1&"*",INDIRECT($D2),0)),LEN(INDEX(INDIRECT($D2),MATCH(F$1&"*",INDIRECT($D2),0)))-LEN(F$1)),"Nil"))
 
Last edited by a moderator:
Upvote 0
Power Query as alternative:
[User]uidlast_namefirst_nameemail_addressaccessibilitySAPME:DEFAULT SITErolegroup
{moderator removed}{moderator removed}Gerald{moderator removed}0XX92SAP_XMII_User;SAP_ME_USER;Administrators;
Rob{moderator reomved}SAP_ME_USER;SAP_XMII_User;
ArunSAP_XMII_User;SAP_ME_INTEGRATOR;SAP_XMII_DynamicQuery;SAP_XMII_Developer;

Code:
// data
let
    Source = Csv.Document(File.Contents("path_to_the-file\data.txt"),[Delimiter=",", Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    SplitE = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    USC = Table.RemoveColumns(Table.Unpivot(Table.ReplaceValue(SplitE,null,"User",Replacer.ReplaceValue,{"Column1.2"}), {"Column1.2"}, "Attribute", "Value"),{"Attribute"}),
    Group = Table.AddColumn(Table.Group(USC, {"Column1.1"}, {{"Count", each _, type table}}), "Custom", each List.Distinct(Table.Column([Count],"Value"))),
    Extract = Table.RemoveColumns(Table.TransformColumns(Group, {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),{"Count"}),
    SplitComma = Table.SplitColumn(Extract, "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3"}),
    ReplaceBack = Table.ReplaceValue(Table.PromoteHeaders(Table.Transpose(SplitComma), [PromoteAllScalars=true]),"User",null,Replacer.ReplaceValue,{"[User]"})
in
    ReplaceBack
 
Upvote 0

Forum statistics

Threads
1,216,736
Messages
6,132,426
Members
449,727
Latest member
Aby2024

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