wmic CSV output contains a value which contains multiple ","s causing python's CSV parser to fail. This is an obvious bug in wmic which microsft wants me to pay money to tell them about. Question is, "Is there a way to circumvent or work around this grotesque misuse of the CSV format."
Example BAD output from CSV: C:\Users\Administrator\Desktop>wmic diskdrive get model /format:csv
Node,Model FakeHOST,HP LOGICAL VOLUME SCSI Disk Device FakeHOST, Duo 2.41TB, port 0, FASTDrive 1200GB FakeHOST, Duo 2.41TB, port 1, FASTDrive 1200GB Example output of what windows should be displaying:
C:\Users\Administrator\Desktop>wmic diskdrive get model /format:csv Node,Model FakeHOST, "HP LOGICAL VOLUME SCSI Disk Device" FakeHOST, "Duo 2.41TB, port 0, FASTDrive 1200GB" FakeHOST, "Duo 2.41TB, port 1, FASTDrive 1200GB" The problem is not so pronounced with this shortened output. However, I use this only to express the problem. What I need to do is reliably, including blank values, get the information for all disks currently in the system. Ideally this would be accompolished usinging.
wmic diskdrive list /format:csv However, due to the before mentioned problems.. this will fail miserably..
Is there a magic parameter that I am missing from the output of wmic that might let wmic print the csv escape characters to allow this output to be parsed correctly? Does windows not care about this problem? Am I alone in the Universe? I know that one can also get XML out from wmic. However, the xml output from wmic is very fluffy and messy. If one has to use xml to solve this problem, how does one get this into values that are meaningful in python?
No comments:
Post a Comment