Hi all, please advise how can I transpose the information(those highlighted in yellow) on the left in to a table form on the right?
To give a bit more context, the original file is in txt form and I used generate data table to read the txt file. The output of the generate data table is what you see on the left of the screenshot.
Welcome to the community
as you are reading the data from text fiel…first split the data based using str.Split({"default:","root:","user1:"},StringSplitOptions.RemoveEmptyEntries)
this give you an array of string arr(0) is the string for default: arr(1) is for root: and arr(2) is for user1:
So you can use 3 generate tables and get 3 different tables for each
Now…use join Datatable with full join and join on the first column of each table so that you get the final output
extra columns you dont need can be removed using filter datatable which has fucntionality to remove columns also
Hope this helps
cheers
hihi Anil_G,
Thanks for the prompt reply. However, the list of users are not fixed, so i cant hardcode the list.
To give a better idea, below is an extract of the raw text file:
- VALID USER ATTRIBUTES FOR /ETC/SECURITY/USER:
- account_locked Defines whethter the account is locked. Locked accounts cannot be used for logins.
- histexpire Defines the period of time in weeks that a user will not be able to reuse a password.
-
Possuble values: an integer value between 0 and 260.
- histsize
- maxage Defines the maximum number of weeks a password is valid. The default is 0, which is equivalent to unlimited.
-
The value is a decimal integer string. The default is a value of 0, indicating no minimum number.
- mindiff Defines the minimum number of characters required in a new password that were not in the old password.
-
The value is a decimal integer string. The default is a value of 0, indicating no minimum number.
- minlen Defines the minimum length of a password. The value is a decimal integer string.
-
The default is a value of 0, indicating no minimum length. The maximum value allowed is 8. This attribute is determined by the minalpha attribute value added to the minother attribute value. If the sum of these values is greater than the minlen attribute value, the minimum length is set to the result.
- minother Defines the minimum number of non-alphabetic characters that must be in a new password.
-
the value is a decimal integer string. The default is a value of 0, indicating no minimum number.
default:
admin = false
login = true
su = true
daemon = true
rlogin = true
sugroups = ALL
admgroups =
ttys = ALL
auth1 = SYSTEM
auth2 = NONE
tpath = nosak
umask = 077
expires = 0
SYSTEM = “compat”
logintimes =
pwdwarntime = 5
account_locked = false
loginretries = 3
histexpire = 52
histsize = 20
minage = 0
maxage = 8
maxexpired = 1
minalpha = 2
minother = 2
minlen = 8
mindiff = 4
maxrepeats = 2
dictionlist = /usr/share/dict/words
pwdchecks =
dce_export = false
root:
admin = false
login = true
su = true
daemon = true
rlogin = true
sugroups = ALL
admgroups =
ttys = ALL
auth1 = SYSTEM
auth2 = NONE
tpath = nosak
umask = 077
expires = 0
SYSTEM = “compat”
logintimes =
pwdwarntime = 5
account_locked = false
loginretries = 3
histexpire = 52
histsize = 20
minage = 0
maxage = 8
maxexpired = 1
minalpha = 2
minother = 2
minlen = 8
mindiff = 4
maxrepeats = 2
dictionlist = /usr/share/dict/words
pwdchecks =
dce_export = false
user1:
admin = false
login = true
su = true
daemon = true
rlogin = true
sugroups = ALL
admgroups =
ttys = ALL
auth1 = SYSTEM
auth2 = NONE
tpath = nosak
umask = 077
expires = 0
SYSTEM = “compat”
logintimes =
pwdwarntime = 5
account_locked = false
loginretries = 3
histexpire = 52
histsize = 20
minage = 0
maxage = 8
maxexpired = 1
minalpha = 2
minother = 2
minlen = 8
mindiff = 4
maxrepeats = 2
dictionlist = /usr/share/dict/words
pwdchecks =
dce_export = false
user2:
admin = false
login = true
su = true
daemon = true
rlogin = true
loginretries = 3
histexpire = 13
histsize = 20
minage = 0
maxage = 8
user3:
admin = false
login = true
su = true
daemon = true
rlogin = true
loginretries = 3
histexpire = 13
histsize = 20
minage = 0
maxage = 8
rachel:
admin = true
login = true
su = true
daemon = true
rlogin = true
loginretries = 3
histexpire = 13
histsize = 20
minage = 0
maxage = 8
mike:
loginretries = 3
histexpire = 13
histsize = 20
minage = 0
maxage = 8
<<EOF
What i intend to do is to read the text file, extract lines that does not start with * and then transpose the info into table form. I tried using regex to find all that starts with “*” but it doesnt work. That was why i used generate data table but i couldnt figure out how to transpose the info into table form. Please advise. Thanks in advance.
No where you are hardcoding the usernames …if you are taling about user1…then we can use regex split which will split on : lines
System.Text.RegularExpressions.Regex.Split(str,".*:",RegexOptions.MultiLine)
This gives array splitting on the colon lines and then assign eqch to separate table and join them back
Cheers