[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Python

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello

I am trying to connect Zapier on an MS SQL 2014 instance I am running on one of our servers.

I can connect fine using heidisql.

When connecting from Zapier I get an authentication error:

(pyodbc.ProgrammingError) ('42000', "[42000] [unixODBC][FreeTDS][SQL Server]Login failed for user 'someuser'. (18456) (SQLDriverConnect)")

Open in new window


So this means that the network connexion itself is working but somehow their Python based connector doesn't manage to authenticate.

We used mixed mode authentication on said sever and I have tried both SQL user and domain user to no avail... Using a complex password as per their suggestions.

Any suggestion / info most welcome (as their support is not too helpful on this one).
0
Why Diversity in Tech Matters
LVL 12
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

I would like to know if it's possible to retrieve an hashed password from ADAM with Python?

I've seen that DSInternals could allow that, but wouldn't work with ADAM.  Plus we don't need the password in clear text, just the hashed version.

(Using Windows Server 2012 R2, ADAM, Python 3.7)

Thanks
0
Here is a quick entry class problem in python. Please take a look.
When a car is rented out, I thought it only delete the item in the self.availableCars,
Why the item was also deleted in the self.OriginalInventory?

for example, we first rent a "Sedan" out and return it back, the price of "Sedan" is shown as $None after we return it.

please help.

Thanks,
RDB



class carRental:
    def __init__(self, listOfCars):
        self.OriginalInventory = listOfCars #make a copy of Original Inventory, so we can look up price when a car is returned.
        self.availableCars = listOfCars

    def displayCars(self):
        print()
        print("Here is a list of available cars for rent")
        print("**************************")
        for car in self.availableCars.keys():
            print("{}:${} per day".format(car,self.availableCars.get(car)))
        print("**************************")
        print()

    def rentOut(self, requestedCar):
        if requestedCar in self.availableCars.keys():
            print("You have requested {}, it is available. It will cost you ${} per day".format(requestedCar, self.availableCars.get(requestedCar)))
            print()
            del self.availableCars[requestedCar]

            print("here is the list of available cars")
            for car in self.availableCars.keys():
                print("{}:${} per day".format(car,self.availableCars.get(car)))

            print("here is the list of car in the original 

Open in new window

0
I would like to know of it's possible to get notified by Active Directory when a user has been added/removed from a group?

Is there a way in python to "subscribe" to have our program notified when this kind of event occur?

The only way i could detect those changes is to pool data periodically to see group changes.

(running python 3.7 on windows server 2012 r2)

yet, i've found pyad and python-ldap modules, but none of them seems to have functions for that.

Note: If it's not possible to be advised, then is there a way to just check with a single call "Is there any changes?"... and if there's some changes, i could browse a complete group to see these changes.

Thanks
0
Hi:

 I need to add a 2nd degree polynomial to my pandas dataset. Not sure how?

import numpy as np
from sklearn.preprocessing import PolynomialFeatures
poly = PolynomialFeatures(2)
poly.fit(X_tr)


X_tr = ?
0
c++ Python program with Minizinc

In this project, you will design and implement a resource management module for an Operating System Simulator ‘oss’. In this project, you will use the deadlock avoidance to manage resources, with processes being blocked on their requests until those requests are safe.
There is no scheduling in this project, but you will be using shared memory so be cognizant of possible race conditions.

Please see the attached files customer has given me piece of codes and SOP document if someone can help me to understand whats the expectation of customer and how to met that expectation i will be very thankful.
1
Create , read and write data to protected files using python
0
Getting errors setting up SublimeText 3 user keymap for View-In-Browser plugin..

My View In Browser settings.sublime-settigs are:
{
	"posix": {
		"darwin": {
			"firefox": "open -a \"/Foreign Apps/Firefox/Firefox Developer Edition.app\"",
			"safari": "open -a \"/Applications/Safari.app\"",
			"chrome": "open -a \"/Foreign Apps/Google/Google Chrome.app\"",
			"opera": "open -a \"/Foreign Apps/Opera/Opera.app\""
		}
	},

	"browser": "firefox"
}

Open in new window


My Default (OSX).sublime-keymap-User are:
[
 
 { "keys": [ "super+e" ], "command": "view-in-browser" },
 { "keys": [ "alt+1” ], “command”: “view_in_browser”, “args”: { “browser”: "firefox" } },
 { "keys": [ "alt+2" ], "command": "view-in-browser", "args": { "browser": "chrome" } },
 { "keys": [ "alt+3" ], "command": "view-in-browser', “args”: { “browser”: “safari” } },
 { "keys": [ "alt+4" ], "command": "view-in-browser", "args": { "browser": "opera" } }
 
]

Open in new window


python console shows: "Error trying to parse file: Unexpected character, expected a comma or closing bracket in Packages/User/Default (OSX).sublime-keymap:4:95"

Can somebody point out the error, because I just can't see it.
0
hi Apple folks

i prefer using Xcode for Python programming but i notice it has no native support (or full-featured) for debugging Python using Xcode. or, probably i missed something with Xcode?

basically, how can i have full-featured debug functions for Python code using Xcode?

thanks,
bbao
0
Using:
  • Microsoft Visual Code 1.28.2 x64
  • Python 3.7

I've the smallest code ever
import ldap
print (ldap.__version__)

Open in new window


And i'm getting the error:
  • Exception has occured: ModuleNotFoundError
  • "No module named 'ldap'

I've installed the Wheel found on Christoph Gohlke web site.
using this command: pip install .\python_ldap-3.1.0-cp37-cp37m-win32.whl

I've checked the dependencies as shown here:
Capture.PNG
What am i missing?

Because when i run the following command in terminal, i'm getting "3.1.0" which mean that it can find the ldap module.
python -c "import ldap;print (ldap.__version__)"

Thanks a lot for your help
0
JavaScript Best Practices
LVL 12
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

I need a script written to take a large xml file and extract information into a csv or directly to an MS SQL Database.  Preferably in powershell.

Attached is the a 'sample' of the XML file.  The actual file size is ~800 mb.  I have a Python script that plods through it on smaller file sizes (~14mb), but will take an amazing amount of time for the large file.  Really even a script to preprocess the file and take out all the line items with ServicePointChannelID with the 400 range would be nice, then my python script would work good.

Attached is a sample xml file, a sample output file, and the python script that creates it.

Ideally it would be nice to go over to powershell with this from Python.
test2.xml
dataexport.csv
dataexport.py
0
I have a public API endpoint that I am pulling a json file every 30 mins. Right now I am using a python pandas dataframe to pull and upload the file to a cloud storage bucket and then sending to pub sub to process and place into BQ. The problem with this is that the file name stays the same and even though I have  gcs text stream to pub sub if it reads the file once it never reads it again even though the file attributes have changed. My question here is can any one help me with code that will pull from an api web link and stream the data directly to pub sub?

Sample code below:
import json
import pandas as pd
from sodapy import Socrata
from io import StringIO
import datalab.storage as gcs
from google.oauth2 import service_account

client = Socrata("sample.org", None)
results = client.get("xxx")

# Convert to pandas DataFrame
results_df = pd.DataFrame.from_records(results, columns =['segmentid','street','_direction','_fromst','_tost','_length','_strheading','_comments','start_lon','_lif_lat','lit_lon','_lit_lat','_traffic','_last_updt'])
# send results to GCP
gcs.Bucket('test-temp').item('data.json').write_to(results_df.to_json(orient='records', lines=True),'text/json')
0
Hi,
I'm trying to create a pandas DataFrame from some json, which has a series of arrays. I've tried the code below, but I get an empty DataFrame.
The expected output is:

id               name
_________________
2546558   A1
2156478   A2
3654785   A3
1236489   A4
7896324   B1
1597532   B2
9512347   B3
7536972   B4

import pandas as pd
import json

data = [  
   [  
      {  
         'id':2546558,
         'name':'A1',
      },
      {  
         'id':2156478,
         'name':'A2',
      },
      {  
         'id':3654785,
         'name':'A3',
      },
      {  
         'id':1236489,
         'name':'A4',
      }
   ]
    ,
   [  
      {  
         'id':7896324,
         'name':'B1',
      },
      {  
         'id':1597532,
         'name':'B2',
      },
      {  
         'id':9512347,
         'name':'B3',
      },
      {  
         'id':7536972,
         'name':'B4',
      }
   ]
]
   
val = json.loads(json.dumps(data))

val = pd.DataFrame(val)

def getreadings(dict):
    d = pd.DataFrame()
    d['id'] = dict['id']
    d['name'] = dict['name']
    return d

df = pd.DataFrame()
for i in range(len(val)):
    df1 = getreadings(val.iloc[i,1])
    df = df.append(df1)
    
print(df)

Open in new window

0
Hi
We talked a little about my approach to teaching neighborhood kids and adults, even, how to code.
I think we decided against going all out on Python right away. Do you still agree? I'd like to hold off on Python for a pure newbie.
K-12 focuses on Java, so I think Java for them is obvious.
I also think so, because polymorphism and class design will be important for making tablet, phone apps, as they are seriously non-novice projects. - Java will make 4 an easy transition
I'm going to start them off on Java and when they are blatantly ready, switch to Python, or their preferred device.
I could do Java and Python side-by-side?
Any suggestions?
Thanks
I'll start early next year

My padowan coders will excel
0
well  how can I decode the emails  so i can get plain text?

import poplib;

import io;

import string;

import encodings;

try:

 server = poplib.POP3_SSL("pop.gmail.com",poplib.POP3_SSL_PORT);

   

except:

 print("Error");



response = server.user('XXXXXXXX@gmail.com');

response1 =  server.pass_('XXXXXXXX');

print(response);

print(response1);



# download the first message in the list


messages = server.list();

print(messages);
   

























  

Open in new window


help appreciated
0
Hi, need help to create 1000 VMs to map with direct network ID from python script to call API but it didn't well.

Direct network error: private cloud contains network[1c948756-db50-4871-b03d-d911ecdcae16]', 'code': '400'}}"

Virtual Private Cloud no issue but just can't ping the IP from Python Script being created but when using UI to create and point to the direct network is okay.

Where can i find the right API call to query the direct network ID?

You see click on the below link to download  from google Drive to view the creation process for better understand.

https://drive.google.com/file/d/1ZgYSXrUiODPQk_v6HV7sUZD_UpQ6DMJQ/view?usp=sharing

Thanks.
0
hi, how to understand and resolve this error when deleting 1000VMs from python script. Tks

message":"The maximum request receiving rate is exceeded","request_id
0
Need a python script to copy yesterday files to a destination location and gzip them in destination directory
0
Hi,

Ps advice the below error which require python code to report output status like created successfully of VM of cloud. Tks.

Code:




Error
C:\Users\P1319181\PycharmProjects\fusion\venv\Scripts\python.exe C:/Users/P1319181/PycharmProjects/fusion/main_v1.py
How many volumes/VMs you want to create: 1
Enter the start number: 1
C:\Users\P1319181\PycharmProjects\fusion\venv\lib\site-packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
C:\Users\P1319181\PycharmProjects\fusion\venv\lib\site-packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
C:\Users\P1319181\PycharmProjects\fusion\venv\lib\site-packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
Traceback (most recent call last):
  File "C:/Users/P1319181/PycharmProjects/fusion/main_v1.py", line 71, in <module>
    json.dump(error_file, error_data)
  File …
0
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Dear Experts

I am reading in Python eml files, in this format I keep my archived emails. I am just starting with python so I usually stop quite often realizing that I cannot manage something which must be quite easy.

Now I stopped on international header, exactly From:

There is this string in email file right after keyword From: =?UTF-8?Q?Martin_Bo=C4=8Dan_ACTIVE24?= <helpdesk@active24.cz>

It is simply name of operator from big Czech internet company providing internet services. that name correctly displayed is "Martin Bočan ACTIVE24 <helpdesk@active24.cz>"

Is there a way I can decode that string and work with it?

Many thanks

Vladimir
0
Hi,

ps advice how to resolve the error. Tks

1.jpg
0
My computer operating system is Windows 7 pro .  

I am trying unsuccessfully to find code in Github.  I need help using the search feature.  Yes, I have searched Experts-Exchange first before posting this message.  I guess I just don’t know what key words to enter.

I have to write a program to switch last name, first name to first name, last name.  I am not a coding expert.  I was hoping to find some vbscript code which would perform the task.  I have to deal with all kinds of names.  In the data I have to convert  there are names with 3 elements like:

Joe Jones Hopkins

Then there are people who have just one name.  
And there are people with suffixes like Jr and III .  Example Joe Jones jr.  etc.

Please explain in detail how you would use Github search to find suitable code to do the above.  I would prefer vbscript but Python code would be suitable also.

Or may be there is an Experts-Exchange article which would help.

Thank you for your help.
0
hi, i can get postman to POST to create a VM but using pycharm encountered this error.

code 1: obtain a token
==========================================================================
import requests
url = "https://IP/silvan/apigateway/v1.0/"
get_apis = "apis_include_throttles"

##API URLs
get_token_url = "https://iam-apigateway-proxy.domain.com/v3/auth/tokens"

create_volume_url = "https://evs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes"
delete_volume_url = "https://evs.stic-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes/"
create_vm_url = "https://ecs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/servers"



##Images Dictionary
images = {
    "Ubuntu 18.10": "5313ace4-4573-404b-abc6-8548ed14c4f7",
    "RHEL7.5-40G": "aa9d05f3-cb90-4776-9c02-617a9906b271",
    "WindowsServer2016WithGUI": "c54d05fa-5ad8-425e-be56-e60ede395230",
    "Windows10Pro": "29caef55-0617-4813-8a17-cb0bef19de16",
    "RHEL7.5": "c5ccd8a7-d8f3-4a4c-91c3-9d93303aee58",
    "Ubuntu16.04LTS": "3f8948fd-c108-48db-9951-1d617e8e5b03",
    "image-kvm-euler": "298e2912-5a7a-4178-8ac4-b260712d514c",
    "image-ManageOne": "80d9b0ee-a5b3-42fe-99ed-fc32c57da5b3",
    "esight_image": "e1e94234-f3e7-4793-8bdb-0cef9e3194cf"
}


def get_token():
    body = {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
    …
0
i would look like ro analyse/describe data that is big over 300,000,000 rows do you python can be able to help me do this. how efficiently can i do thos
1
Hi,
I have some json data that I'm converting to a pandas DataFrame. I'd like to make the current index column the 'code' column and reset the index, so the output would be:

      code      parameters                       units
1      1              Temperature               C
2      10              Specific Conductivity      NaN
3      11              Resistivity                      NaN
4      113              NaN                              ppm
5      114       NaN                              ppt
6      117       NaN                              mg/L


This is my example python code:

import pandas as pd
import json
import requests

data = {  
   'parameters':{  
      '22':'NO₃⁻',
      '23':'NH₄⁺',
      '24':'Cl⁻',
      '25':'Turbidity',
      '26':'Battery Voltage',
      '49':'Velocity',
      '28':'Flow Rate',
      '29':'Total Flow (volume)',
      'flowVelocity':'Flow Velocity',
      '50':'Chl-a Concentration',
      '51':'Chl-a Fluorescence',
      '30':'Partial Pressure O₂',
      '31':'Total Suspended Solids',
      '54':'BGA-PC Concentration',
      '32':'External Voltage',
      '10':'Specific Conductivity',
      '55':'BGA-PC Fluorescence',
      '33':'Battery Level',
      '11':'Resistivity',
      '34':'RWT Concentration',
      '12':'Salinity',
      '35':'RWT Fluorescence',
      '13':'Total Dissolved Solids',
      '58':'BGA-PE Concentration',
      '36':'Cl⁻ mV',
      '14':'Density',
      '59':'BGA-PE Fluorescence',
      'density':'Density',
      '37':'NO₃⁻ as N',
      '16':'Baro',
      '38':'NO₃⁻ mV',
      '39':'NH₄⁺ 

Open in new window

0

Python

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.