Answer the question
In order to leave comments, you need to log in
How to fix a small fragment in a txt file using python?
Good day, I have a small problem. You need to get the file from the site standards.ieee.org/develop/regauth/oui/oui.txt
download the file no problems, I would like to convert all this text to json format, I found the script on github, but for some reason it does not work correct, it writes the following to the file
{ "oui": "3C-D9-2B", "vendor": "Hewlett Packard
"},
#!/usr/bin/awk -f
# Parse IEEE OUI vendor list to JSON
# http://standards.ieee.org/develop/regauth/oui/oui.txt
# ---
# Usage:
# $ chmod +x parseoui.awk
# $ wget http://standards.ieee.org/develop/regauth/oui/oui.txt
# $ ./parseoui.awk oui.txt > oui.json
BEGIN {
print "[";
}
/(hex)/ {
printf "{ \"oui\": \"%s\", \"vendor\": \"%s\"},\n", $1, substr($0, index($0, $3));
}
END {
print "]";
}
Answer the question
In order to leave comments, you need to log in
#!/usr/bin/awk -f
# Parse IEEE OUI vendor list to JSON
# http://standards.ieee.org/develop/regauth/oui/oui.txt
# ---
# Usage:
# $ chmod +x parseoui.awk
# $ wget http://standards.ieee.org/develop/regauth/oui/oui.txt
# $ ./parseoui.awk oui.txt > oui.json
BEGIN {
print "[";
}
/(hex)/ {
printf "{ \"oui\": \"%s\", \"vendor\": \"%s\"},\n", $1, substr($0, index($0, $3),length($3));
}
END {
print "]";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question