Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: CSV not printing apostrophe correctly
Post: RE: CSV not printing apostrophe correctly

Thanks for all the replies. The CSV write code is above. This is the read code. I am running Python 3.10.6 if os.path.exists(full_report_path): print(f'Reading report {full_report_path}')...
bazcurtis General Coding Help 8 2,497 Aug-22-2022, 04:28 PM
    Thread: CSV not printing apostrophe correctly
Post: RE: CSV not printing apostrophe correctly

When I read in one of the reports on a Mac it works fine, I get the correct character. When I read the same file on a PC I get a charmap error. Why would Python be different on a Mac or PC? [Image: h...
bazcurtis General Coding Help 8 2,497 Aug-22-2022, 07:55 AM
    Thread: CSV not printing apostrophe correctly
Post: RE: CSV not printing apostrophe correctly

(Aug-17-2022, 09:18 PM)deanhystad Wrote: Don't use utf-8 encoding. It is too restrictive. You should probably specify a dialect. Thanks for reply. I have fixed it partly by doing this. I was not e...
bazcurtis General Coding Help 8 2,497 Aug-18-2022, 10:36 AM
    Thread: CSV not printing apostrophe correctly
Post: CSV not printing apostrophe correctly

Hi, I have a report that contains a lot of Mac machine names. Users seem to love apostrophes in the name. I am getting this in my csv administrator‚Ä≤s Mac It should read administrator’s Mac Thi...
bazcurtis General Coding Help 8 2,497 Aug-17-2022, 08:11 PM
    Thread: Add a new line to a CSV in one column
Post: RE: Add a new line to a CSV in one column

Thanks for the help. I will take a look and give it a try
bazcurtis General Coding Help 7 3,031 Sep-01-2020, 01:31 PM
    Thread: Add a new line to a CSV in one column
Post: RE: Add a new line to a CSV in one column

I had a feeling that would be the case. I am happy for it to look like this in Excel if this is possible name, date, machine, alert1 blank cell, blank cell, blank cell, alert2 blank cell, blank cell,...
bazcurtis General Coding Help 7 3,031 Sep-01-2020, 01:05 PM
    Thread: Add a new line to a CSV in one column
Post: RE: Add a new line to a CSV in one column

Thanks for replying. Sorry if I didn't explain it very well. The cell with the manual clean up in it is made up of a list. At the moment it outputs as one long list making the column very wide. I wo...
bazcurtis General Coding Help 7 3,031 Sep-01-2020, 12:00 PM
    Thread: Add a new line to a CSV in one column
Post: Add a new line to a CSV in one column

Hi, I have a report that is stored in a list. One of the columns will return multiple entries. I would like to a new line between each entry. Is this possible? My report code is with open(full_...
bazcurtis General Coding Help 7 3,031 Sep-01-2020, 10:01 AM
    Thread: Works with Curl. Can't get it to work in Python
Post: RE: Works with Curl. Can't get it to work in Pytho...

That did indeed work. Thank you very much. Can you please tell me why. I had to remove this line result = request_result.json()as I assume I am no longer getting json back. I need to get the HTML ou...
bazcurtis General Coding Help 3 2,571 May-07-2020, 07:47 AM
    Thread: Works with Curl. Can't get it to work in Python
Post: RE: Works with Curl. Can't get it to work in Pytho...

I have made some progress. The below will give me a 200. files = { 'file': open('/Users/Shared/Reports/file.exe', 'rb'), # 'report_format': 'html' }but I need to send the report f...
bazcurtis General Coding Help 3 2,571 May-06-2020, 12:59 PM
    Thread: Works with Curl. Can't get it to work in Python
Post: Works with Curl. Can't get it to work in Python

Hi, I am not sure what I have missed, but I can't get this Curl command to work with the code below. What am I missing? I am getting a 400 returned. The Curl is curl -X POST "URL" -H "Authorizati...
bazcurtis General Coding Help 3 2,571 May-06-2020, 08:45 AM
    Thread: Splitting a string twice
Post: Splitting a string twice

Hi, I am splitting a string at a comma and then at a colon. Although this is working I think there must be a nice way. cn_only = computer_attributes.split(',')[0] cn_only = c...
bazcurtis General Coding Help 2 5,558 Mar-08-2020, 01:22 PM
    Thread: Is this doable?
Post: Is this doable?

Hi, Sorry I don't have any code, but before I try and attempt this I wanted to know if it was doable. I have a pcapng file and all I want to do is list all the TLS certificate used in that session. T...
bazcurtis Networking 1 1,713 Feb-23-2020, 12:23 PM
    Thread: Parsing JSON with backslashes
Post: RE: Parsing JSON with backslashes

(Jan-24-2020, 06:21 PM)micseydel Wrote: You might be able to achieve that with a custom parser but I really, really wouldn't recommend that. If a regular Python file doesn't work for you, I'd recomm...
bazcurtis General Coding Help 3 9,339 Feb-08-2020, 01:13 PM
    Thread: Parsing JSON with backslashes
Post: Parsing JSON with backslashes

I have a script where the users will need to edit some variables. I don't want them to mess the script up so decided I would make a config json file where they could just edit the json rather than edi...
bazcurtis General Coding Help 3 9,339 Jan-24-2020, 04:45 PM
    Thread: CSV gives me blank row on PC, but not a Mac
Post: CSV gives me blank row on PC, but not a Mac

I am using the following code write a CSV file from a List containing Dictionaries When I run it on my Mac it is fine, but when I run it on a PC I get blank rows between each data line. Why is this? ...
bazcurtis General Coding Help 2 2,800 Jan-05-2020, 10:24 AM
    Thread: LDAP3 not return a list correctly?
Post: LDAP3 not return a list correctly?

Hi, I am using LDAP3 to retrieve every computer in my domain. from ldap3 import Server, Connection, ALL ad_computer_list = [] # Procedure to get AD computers def get_ad_computers(): search_dom...
bazcurtis General Coding Help 0 2,656 Dec-23-2019, 04:20 PM
    Thread: Not equal a dictionary key value
Post: RE: Not equal a dictionary key value

Actually it does work. The issue turns out to be that in some cases the key value is blank. I need to check that threats has a value. I am getting a KeyError: 'threats'. I thought it was due to the !=...
bazcurtis General Coding Help 2 1,941 Dec-11-2019, 11:15 PM
    Thread: Not equal a dictionary key value
Post: Not equal a dictionary key value

I have the follow code that works fine if 'bad' == computer_dictionary['threats']: get_threats(computers_url, computer_dictionary['id'])but I want to do if 'good' != computer_dictiona...
bazcurtis General Coding Help 2 1,941 Dec-11-2019, 11:56 AM
    Thread: Retrieving dictionary keys within with another dictionay
Post: RE: Retrieving dictionary keys within with another...

Thanks Craig, I will take a look. Sorry, I thought you were giving me a hint via my code :)
bazcurtis General Coding Help 8 2,855 Oct-29-2019, 10:06 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020