kanzure / python-wmi-client-wrapper

Linux-only wrapper around wmi-client for WMI (Windows)
Other
27 stars 26 forks source link

Newlines not handled properly #4

Open totycro opened 9 years ago

totycro commented 9 years ago

Hi,

I just realized that there are problems if e.g. entries of Win32_NTLogEvent contain newlines. Then, the output is not vaild CSV (the CSV reader will still accept it, but the output is wrong).

In my code, I was attempting to "fix" these lines by making sure that they contain the right number of delimiters, but that's obviously not nice and there are cases where this does not work.

regards, totycro

brsdurkut commented 8 years ago

5

I had same problem. If you add that line to 'wrapper.py', it can be solved. It's ok for me. section = section.replace('\r\n', '\\r\\n')

for section in sections:
            # remove the first line because it has the query class
            section = "\n".join(section.split("\n")[1:])
            section = section.replace('\r\n', '\\r\\n')

            strio = StringIO(section)

            moredata = list(csv.DictReader(strio, delimiter=delimiter))
            items.extend(moredata)